Public Function Pinyin(MyStr As String) As String
If Len(Trim(MyStr)) = 0 Then
Pinyin = ""
Exit Function
End If
i As Long
For i = 1 To Len(MyStr)
j = asc(Mid(MyStr, i, 1))
Select Case j
Case -20319 To -20284: Pinyin = Pinyin + "A"
Case -20283 To -19776: Pinyin = Pinyin + "B"
Case -19775 To -19219: Pinyin = Pinyin + "C"
Case -19218 To -18711: Pinyin = Pinyin + "D"
Case -18710 To -18527: Pinyin = Pinyin + "E"
Case -18526 To -18240: Pinyin = Pinyin + "F"
Case -18239 To -17923: Pinyin = Pinyin + "G"
Case -17922 To -17418: Pinyin = Pinyin + "H"
Case -17417 To -16475: Pinyin = Pinyin + "J"
Case -16474 To -16213: Pinyin = Pinyin + "K"
Case -16212 To -15641: Pinyin = Pinyin + "L"
Case -15640 To -15166: Pinyin = Pinyin + "M"
Case -15165 To -14923: Pinyin = Pinyin + "N"
Case -14922 To -14915: Pinyin = Pinyin + "O"
Case -14914 To -14631: Pinyin = Pinyin + "P"
Case -14630 To -14150: Pinyin = Pinyin + "Q"
Case -14149 To -14091: Pinyin = Pinyin + "R"
Case -14090 To -13319: Pinyin = Pinyin + "S"
Case -13318 To -12839: Pinyin = Pinyin + "T"
Case -12838 To -12557: Pinyin = Pinyin + "W"
Case -12556 To -11848: Pinyin = Pinyin + "X"
Case -11847 To -11056: Pinyin = Pinyin + "Y"
Case -11055 To -10247: Pinyin = Pinyin + "Z"
Case -9254: Pinyin = Pinyin + "Z" ''圳
Case -3589: Pinyin = Pinyin + "Q" ''覃
Case -32185: Pinyin = Pinyin + "C" ''侴
Case Else: Pinyin = Pinyin
End Select
Next i
End Function
If Len(Trim(MyStr)) = 0 Then
Pinyin = ""
Exit Function
End If
i As Long
For i = 1 To Len(MyStr)
j = asc(Mid(MyStr, i, 1))
Select Case j
Case -20319 To -20284: Pinyin = Pinyin + "A"
Case -20283 To -19776: Pinyin = Pinyin + "B"
Case -19775 To -19219: Pinyin = Pinyin + "C"
Case -19218 To -18711: Pinyin = Pinyin + "D"
Case -18710 To -18527: Pinyin = Pinyin + "E"
Case -18526 To -18240: Pinyin = Pinyin + "F"
Case -18239 To -17923: Pinyin = Pinyin + "G"
Case -17922 To -17418: Pinyin = Pinyin + "H"
Case -17417 To -16475: Pinyin = Pinyin + "J"
Case -16474 To -16213: Pinyin = Pinyin + "K"
Case -16212 To -15641: Pinyin = Pinyin + "L"
Case -15640 To -15166: Pinyin = Pinyin + "M"
Case -15165 To -14923: Pinyin = Pinyin + "N"
Case -14922 To -14915: Pinyin = Pinyin + "O"
Case -14914 To -14631: Pinyin = Pinyin + "P"
Case -14630 To -14150: Pinyin = Pinyin + "Q"
Case -14149 To -14091: Pinyin = Pinyin + "R"
Case -14090 To -13319: Pinyin = Pinyin + "S"
Case -13318 To -12839: Pinyin = Pinyin + "T"
Case -12838 To -12557: Pinyin = Pinyin + "W"
Case -12556 To -11848: Pinyin = Pinyin + "X"
Case -11847 To -11056: Pinyin = Pinyin + "Y"
Case -11055 To -10247: Pinyin = Pinyin + "Z"
Case -9254: Pinyin = Pinyin + "Z" ''圳
Case -3589: Pinyin = Pinyin + "Q" ''覃
Case -32185: Pinyin = Pinyin + "C" ''侴
Case Else: Pinyin = Pinyin
End Select
Next i
End Function