Foxtable安装目录里有一个ChnCharInfo.dll,引用一下,然后代码改改
Public Function GetPinYin2(text As String, mode As Short) As String
Dim fnt As New Pinyin4net.Format.HanyuPinyinOutputFormat
fnt.ToneType = Pinyin4net.Format.HanyuPinyinToneType.WITHOUT_TONE
fnt.VCharType = Pinyin4net.Format.HanyuPinyinVCharType.WITH_U_UNICODE
Dim sb As New StringBuilder
For Each c As Char In text
If Microsoft.International.Converters.PinYinConverter.ChineseChar.IsValidChar(c) Then
If mode = 0 Then
sb.Append(" " & Pinyin4net.PinyinHelper.ToHanyuPinyinStringArray(c, fnt)(0))
Else
sb.Append(Pinyin4net.PinyinHelper.ToHanyuPinyinStringArray(c, fnt)(0)(0))
End If
Else
sb.Append(c)
End If
Next
Return sb.ToString().Trim
End Function