首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

怎么得到汉字的拼音

2012-01-15 
如何得到汉字的拼音?如何得到汉字的拼音如:我输入 一 得到 yi 有哪位大侠知道,谢谢了[解决办法]KiteGi

如何得到汉字的拼音?
如何得到汉字的拼音如:我输入 "一 "得到 "yi "有哪位大侠知道,谢谢了

[解决办法]
KiteGirl(小仙妹) 写的这个东西
(点“下载”下载ZIP文件。代码在vbs文件里,是VBScript写的)
http://smallfairy.51.net/KiteGirl/PYGet.htm
[解决办法]
'下边我给你一个函数吧...我认为还可以...调用方法见最后...
'代码不是我自己写的.是从网上找来的..共享一下..


Public Function GetPy(mystr As String) As String
If Asc(mystr) < 0 Then
If Asc(Left(mystr, 1)) < Asc( "啊 ") Then
GetPy = "0 "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "啊 ") And Asc(Left(mystr, 1)) < Asc( "芭 ") Then
GetPy = "A "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "芭 ") And Asc(Left(mystr, 1)) < Asc( "擦 ") Then
GetPy = "B "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "擦 ") And Asc(Left(mystr, 1)) < Asc( "搭 ") Then
GetPy = "C "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "搭 ") And Asc(Left(mystr, 1)) < Asc( "蛾 ") Then
GetPy = "D "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "蛾 ") And Asc(Left(mystr, 1)) < Asc( "发 ") Then
GetPy = "E "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "发 ") And Asc(Left(mystr, 1)) < Asc( "噶 ") Then
GetPy = "F "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "噶 ") And Asc(Left(mystr, 1)) < Asc( "哈 ") Then
GetPy = "G "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "哈 ") And Asc(Left(mystr, 1)) < Asc( "击 ") Then
GetPy = "H "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "击 ") And Asc(Left(mystr, 1)) < Asc( "喀 ") Then
GetPy = "J "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "喀 ") And Asc(Left(mystr, 1)) < Asc( "垃 ") Then
GetPy = "K "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "垃 ") And Asc(Left(mystr, 1)) < Asc( "妈 ") Then
GetPy = "L "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "妈 ") And Asc(Left(mystr, 1)) < Asc( "拿 ") Then
GetPy = "M "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "拿 ") And Asc(Left(mystr, 1)) < Asc( "哦 ") Then
GetPy = "N "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "哦 ") And Asc(Left(mystr, 1)) < Asc( "啪 ") Then
GetPy = "O "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "啪 ") And Asc(Left(mystr, 1)) < Asc( "期 ") Then
GetPy = "P "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "期 ") And Asc(Left(mystr, 1)) < Asc( "然 ") Then
GetPy = "Q "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "然 ") And Asc(Left(mystr, 1)) < Asc( "撒 ") Then
GetPy = "R "


Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "撒 ") And Asc(Left(mystr, 1)) < Asc( "塌 ") Then
GetPy = "S "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "塌 ") And Asc(Left(mystr, 1)) < Asc( "挖 ") Then
GetPy = "T "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "挖 ") And Asc(Left(mystr, 1)) < Asc( "昔 ") Then
GetPy = "W "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "昔 ") And Asc(Left(mystr, 1)) < Asc( "压 ") Then
GetPy = "X "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "压 ") And Asc(Left(mystr, 1)) < Asc( "匝 ") Then
GetPy = "Y "
Exit Function
End If
If Asc(Left(mystr, 1)) > = Asc( "匝 ") Then
GetPy = "Z "
Exit Function
End If
Else
If UCase(mystr) <= "Z " And UCase(mystr) > = "A " Then
GetPy = UCase(Left(mystr, 1))
Else
GetPy = " "
End If
End If
End Function


'调用函数的方法:

Dim j As Integer, str1 As String
j = Len(txt_MSCN.Text)
txt_py.Text = " "
For i = 1 To j
txt_py.Text = txt_py.Text & GetPy(Mid(txt_MSCN.Text, i, 1))
Next i
'该方法有98%的正确率


热点排行