'
函数名 :GetSpellCode
' 函数功能:将汉字转换为大写的拼音首字母
' 传入参数:Cnstr:待转换的汉字字符串
' 返回值 :拼音字符串
' 制作人 :zzz
' 制作日期:2007-02-10
' 说 明 :对于U、V无法转换
Public Function GetSpellCode(ByVal CnStr As String) As String
Dim strTemp As String = ""
Dim iLen As Int16 = CnStr.Length, i As Int16 = 0
For i = 0 To iLen - 1
strTemp += GetCharSpellCode(CnStr.Substring(i, 1))
Next
GetSpellCode = strTemp
End Function
' 函数名 :GetCharSpellCode
' 函数功能:将一个汉字转换为大写的拼音首字母
' 传入参数:Cnstr:待转换的汉字字符
' 返回值 :拼音字符
' 制作人 :zzz
' 制作日期:2007-02-10
' 说 明 :对于U、V无法转换
Private Function GetCharSpellCode(ByVal CnChar As String) As String
Dim iCnChar As Long
Dim Zw() As Byte = 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 ("?")
End If
End Function
' 函数功能:将汉字转换为大写的拼音首字母
' 传入参数:Cnstr:待转换的汉字字符串
' 返回值 :拼音字符串
' 制作人 :zzz
' 制作日期:2007-02-10
' 说 明 :对于U、V无法转换
Public Function GetSpellCode(ByVal CnStr As String) As String
Dim strTemp As String = ""
Dim iLen As Int16 = CnStr.Length, i As Int16 = 0
For i = 0 To iLen - 1
strTemp += GetCharSpellCode(CnStr.Substring(i, 1))
Next
GetSpellCode = strTemp
End Function
' 函数名 :GetCharSpellCode
' 函数功能:将一个汉字转换为大写的拼音首字母
' 传入参数:Cnstr:待转换的汉字字符
' 返回值 :拼音字符
' 制作人 :zzz
' 制作日期:2007-02-10
' 说 明 :对于U、V无法转换
Private Function GetCharSpellCode(ByVal CnChar As String) As String
Dim iCnChar As Long
Dim Zw() As Byte = 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 ("?")
End If
End Function