程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> Visual Basic語言 >> VB綜合教程 >> VB將漢字的首字母轉換為拼音代碼

VB將漢字的首字母轉換為拼音代碼

編輯:VB綜合教程
 

將漢字的首字母轉換為拼音代碼
Public Function py(mystr As String) As String
If Asc(mystr) < 0 Then
If Asc(Left(mystr, 1)) < Asc("啊") Then
py = "0"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("啊") And Asc(Left(mystr, 1)) < Asc("

芭") Then
py = "A"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("芭") And Asc(Left(mystr, 1)) < Asc("

擦") Then
py = "B"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("擦") And Asc(Left(mystr, 1)) < Asc("

搭") Then
py = "C"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("搭") And Asc(Left(mystr, 1)) < Asc("

蛾") Then
py = "D"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("蛾") And Asc(Left(mystr, 1)) < Asc("

發") Then
py = "E"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("發") And Asc(Left(mystr, 1)) < Asc("

噶") Then
py = "F"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("噶") And Asc(Left(mystr, 1)) < Asc("

哈") Then
py = "G"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("哈") And Asc(Left(mystr, 1)) < Asc("

擊") Then
py = "H"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("擊") And Asc(Left(mystr, 1)) < Asc("

喀") Then
py = "J"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("喀") And Asc(Left(mystr, 1)) < Asc("

垃") Then
py = "K"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("垃") And Asc(Left(mystr, 1)) < Asc("

媽") Then
py = "L"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("媽") And Asc(Left(mystr, 1)) < Asc("

拿") Then
py = "M"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("拿") And Asc(Left(mystr, 1)) < Asc("

哦") Then
py = "N"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("哦") And Asc(Left(mystr, 1)) < Asc("

啪") Then
py = "O"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("啪") And Asc(Left(mystr, 1)) < Asc("

期") Then
py = "P"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("期") And Asc(Left(mystr, 1)) < Asc("

然") Then
py = "Q"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("然") And Asc(Left(mystr, 1)) < Asc("

撒") Then
py = "R"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("撒") And Asc(Left(mystr, 1)) < Asc("

塌") Then
py = "S"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("塌") And Asc(Left(mystr, 1)) < Asc("

挖") Then
py = "T"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("挖") And Asc(Left(mystr, 1)) < Asc("

昔") Then
py = "W"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("昔") And Asc(Left(mystr, 1)) < Asc("

壓") Then
py = "X"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("壓") And Asc(Left(mystr, 1)) < Asc("

匝") Then
py = "Y"
Exit Function
End If
If Asc(Left(mystr, 1)) >= Asc("匝") Then
py = "Z"
Exit Function
End If
Else
If UCase(mystr) <= "Z" And UCase(mystr) >= "A" Then
py = UCase(Left(mystr, 1))
Else
py = mystr
End If
End If
End Function
 

 
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved