加了点东东:标点符号,字母,英文保持不变 Public Function HzToPy(Hz As String, Optional Sep As String = "", Optional ShowNotation As Boolean = True, Optional ShowInitialOnly As Boolean, Optional ShowOnlyOneChar As Boolean = True) As String 'modify by Tinus for punctuation and english on Oct.19,2008
Dim hp As HZ2PY, str As String, i, HzStr As String HzStr = Hz '' str = "" Set hp = New HZ2PY '创建类 If Sep <> "" Then hp.Seperator = Sep hp.UseSeperator = True End If hp.InitialOnly = ShowInitialOnly hp.OnlyOneChar = ShowOnlyOneChar For i = 1 To Len(Hz) '' HzStr = Mid(Hz, i, 1) ' MsgBox (Asc(HzStr)) ' MsgBox (Asc("~")) If Asc(HzStr) < 0 And Asc(HzStr) > -21000 Then '目前还不确定是否完全包括 HzStr = hp.GetPinYin(HzStr) '' If Not ShowNotation Then HzStr = hp.AdjustPhoneticNotation(HzToPy, pnNoNotation) HzStr = " " & HzStr & " " End If str = str & HzStr Next i Set hp = Nothing '释放 HzToPy = Replace(Trim(str), " ", " ") '' End Function |