汉字转拼音缩写的函数(VB)
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->PublicFunctiongetPYChar(charAsString)AsString
DimlCharAsLong
lChar=65536+Asc(char)
If(lChar>=45217AndlChar<=45252)ThengetPYChar="A"
If(lChar>=45253AndlChar<=45760)ThengetPYChar="B"
If(lChar>=47761AndlChar<=46317)ThengetPYChar="C"
If(lChar>=46318AndlChar<=46825)ThengetPYChar="D"
If(lChar>=46826AndlChar<=47009)ThengetPYChar="E"
If(lChar>=47010AndlChar<=47296)ThengetPYChar="F"
If(lChar>=47297AndlChar<=47613)ThengetPYChar="G"
If(lChar>=47614AndlChar<=48118)ThengetPYChar="H"
If(lChar>=48119AndlChar<=49061)ThengetPYChar="J"
If(lChar>=49062AndlChar<=49323)ThengetPYChar="K"
If(lChar>=49324AndlChar<=49895)ThengetPYChar="L"
If(lChar>=49896AndlChar<=50370)ThengetPYChar="M"
If(lChar>=50371AndlChar<=50613)ThengetPYChar="N"
If(lChar>=50614AndlChar<=50621)ThengetPYChar="O"
If(lChar>=50622AndlChar<=50905)ThengetPYChar="P"
If(lChar>=50906AndlChar<=51386)ThengetPYChar="Q"
If(lChar>=51387AndlChar<=51445)ThengetPYChar="R"
If(lChar>=51446AndlChar<=52217)ThengetPYChar="S"
If(lChar>=52218AndlChar<=52697)ThengetPYChar="T"
If(lChar>=52698AndlChar<=52979)ThengetPYChar="W"
If(lChar>=52980AndlChar<=53640)ThengetPYChar="X"
If(lChar>=53689AndlChar<=54480)ThengetPYChar="Y"
If(lChar>=54481AndlChar<=52289)ThengetPYChar="Z"
EndFunction
PublicFunctiongetPY(strAsString)AsString
Fori=0ToLen(str)-1
getPY=getPY&getPYChar(Mid(str,i+1,1))
Next
EndFunction
DimlCharAsLong
lChar=65536+Asc(char)
If(lChar>=45217AndlChar<=45252)ThengetPYChar="A"
If(lChar>=45253AndlChar<=45760)ThengetPYChar="B"
If(lChar>=47761AndlChar<=46317)ThengetPYChar="C"
If(lChar>=46318AndlChar<=46825)ThengetPYChar="D"
If(lChar>=46826AndlChar<=47009)ThengetPYChar="E"
If(lChar>=47010AndlChar<=47296)ThengetPYChar="F"
If(lChar>=47297AndlChar<=47613)ThengetPYChar="G"
If(lChar>=47614AndlChar<=48118)ThengetPYChar="H"
If(lChar>=48119AndlChar<=49061)ThengetPYChar="J"
If(lChar>=49062AndlChar<=49323)ThengetPYChar="K"
If(lChar>=49324AndlChar<=49895)ThengetPYChar="L"
If(lChar>=49896AndlChar<=50370)ThengetPYChar="M"
If(lChar>=50371AndlChar<=50613)ThengetPYChar="N"
If(lChar>=50614AndlChar<=50621)ThengetPYChar="O"
If(lChar>=50622AndlChar<=50905)ThengetPYChar="P"
If(lChar>=50906AndlChar<=51386)ThengetPYChar="Q"
If(lChar>=51387AndlChar<=51445)ThengetPYChar="R"
If(lChar>=51446AndlChar<=52217)ThengetPYChar="S"
If(lChar>=52218AndlChar<=52697)ThengetPYChar="T"
If(lChar>=52698AndlChar<=52979)ThengetPYChar="W"
If(lChar>=52980AndlChar<=53640)ThengetPYChar="X"
If(lChar>=53689AndlChar<=54480)ThengetPYChar="Y"
If(lChar>=54481AndlChar<=52289)ThengetPYChar="Z"
EndFunction
PublicFunctiongetPY(strAsString)AsString
Fori=0ToLen(str)-1
getPY=getPY&getPYChar(Mid(str,i+1,1))
Next
EndFunction
本文介绍了一个使用Visual Basic编写的函数,该函数能够将输入的汉字转换为对应的拼音首字母缩写形式。通过一系列条件判断实现了从汉字到拼音缩写的映射。
1487

被折叠的 条评论
为什么被折叠?



