Vb.net 汉字转换成拼音

前端之家收集整理的这篇文章主要介绍了Vb.net 汉字转换成拼音前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

'汉字转换成拼音

比如:“张三100”,可以生成"zs100"

Public Function HzTopy(ByVal mystr As String) As String

Dim i As Integer

Dim J As Integer

Dim Pstr As String = String.Empty

Dim Py As String =string.empty

Dim k As Integer = String.Empty

Try

k = Len(mystr)

For J = 1 To k

i = Asc(Mid(mystr,J,1))

Select Case i

Case -20319 To -20284 : Py = "A"

Case -20283 To -19776 : Py = "B"

Case -19775 To -19219 : Py = "C"

Case -19218 To -18711 : Py = "D"

Case -18710 To -18527 : Py = "E"

Case -18526 To -18240 : Py = "F"

Case -18239 To -17923 : Py = "G"

Case -17922 To -17418 : Py = "H"

Case -17417 To -16475 : Py = "J"

Case -16474 To -16213 : Py = "K"

Case -16212 To -15641 : Py = "L"

Case -15640 To -15166 : Py = "M"

Case -15165 To -14923 : Py = "N"

Case -14922 To -14915 : Py = "O"

Case -14914 To -14631 : Py = "P"

Case -14630 To -14150 : Py = "Q"

Case -14149 To -14091 : Py = "R"

Case -14090 To -13319 : Py = "S"

Case -13318 To -12839 : Py = "T"

Case -12838 To -12557 : Py = "W"

Case -12556 To -11848 : Py = "X"

Case -11847 To -11056 : Py = "Y"

Case -11055 To -10247 : Py = "Z"

Case Else : Py = CStr(Chr(i))

End Select

Pstr = Pstr & Py

Next

HzTopy = Pstr

Catch ex As Exception

msgBox ("转成失败!")

Return String.Empty

End Try

End Function

猜你在找的VB相关文章