汉字转拼音缩写的函数(VB)

本文介绍了一个使用Visual Basic编写的函数,该函数能够将输入的汉字转换为对应的拼音首字母缩写形式。通过一系列条件判断实现了从汉字到拼音缩写的映射。
汉字转拼音缩写的函数(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

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值