'函数名 :GetSpellCode '函数功能:将汉字转换为大写的拼音首字母 '传入参数:Cnstr:待转换的汉字字符串 '返回值 :拼音字符串 '制作人 :zzz '制作日期:2007-02-10 '说 明 :对于U、V无法转换 PublicFunction GetSpellCode()Function GetSpellCode(ByVal CnStr AsString) AsString Dim strTemp AsString="" Dim iLen As Int16 = CnStr.Length, i As Int16 =0 For i =0To iLen -1 strTemp += GetCharSpellCode(CnStr.Substring(i, 1)) Next GetSpellCode = strTemp End Function '函数名 :GetCharSpellCode '函数功能:将一个汉字转换为大写的拼音首字母 '传入参数:Cnstr:待转换的汉字字符 '返回值 :拼音字符 '制作人 :zzz '制作日期:2007-02-10 '说 明 :对于U、V无法转换 PrivateFunction GetCharSpellCode()Function GetCharSpellCode(ByVal CnChar AsString) AsString Dim iCnChar AsLong Dim Zw() AsByte= System.Text.Encoding.Default.GetBytes(CnChar) '如果是字母,则直接返回 Dim i1 As Int16 = Zw(0) Dim i2 As Int16 = Zw(1) iCnChar = i1 *256+ i2 If ((iCnChar >=45217) And (iCnChar <=45252)) Then Return"A" ElseIf ((iCnChar >=45253) And (iCnChar <=45760)) Then Return"B" ElseIf ((iCnChar >=45761) And (iCnChar <=46317)) Then Return"C" ElseIf ((iCnChar >=46318) And (iCnChar <=46825)) Then Return"D" ElseIf ((iCnChar >=46826) And (iCnChar <=47009)) Then Return"E" ElseIf ((iCnChar >=47010) And (iCnChar <=47296)) Then Return"F" ElseIf ((iCnChar >=47297) And (iCnChar <=47613)) Then Return"G" ElseIf ((iCnChar >=47614) And (iCnChar <=48118)) Then Return"H" ElseIf ((iCnChar >=48119) And (iCnChar <=49061)) Then Return"J" ElseIf ((iCnChar >=49062) And (iCnChar <=49323)) Then Return"K" ElseIf ((iCnChar >=49324) And (iCnChar <=49895)) Then Return"L" ElseIf ((iCnChar >=49896) And (iCnChar <=50370)) Then Return"M" ElseIf ((iCnChar >=50371) And (iCnChar <=50613)) Then Return"N" ElseIf ((iCnChar >=50614) And (iCnChar <=50621)) Then Return"O" ElseIf ((iCnChar >=50622) And (iCnChar <=50905)) Then Return"P" ElseIf ((iCnChar >=50906) And (iCnChar <=0.51386)) Then Return"Q" ElseIf ((iCnChar >=51387) And (iCnChar <=51445)) Then Return"R" ElseIf ((iCnChar >=51446) And (iCnChar <=52217)) Then Return"S" ElseIf ((iCnChar >=52218) And (iCnChar <=52697)) Then Return"T" ElseIf ((iCnChar >=52698) And (iCnChar <=52979)) Then Return"W" ElseIf ((iCnChar >=52980) And (iCnChar <=53640)) Then Return"X" ElseIf ((iCnChar >=53689) And (iCnChar <=54480)) Then Return"Y" ElseIf ((iCnChar >=54481) And (iCnChar <=55289)) Then Return"Z" Else Return ("?") EndIf End Function