allwiki首页  
天下维客 你可以修改的网络知识库
首页最近更改优秀条目专题展示电脑科技词典软件学习网络知识电脑安全明星时尚天下百科
 

Asp中获取汉字拼音的第一个字母

天下维客,你可以修改的网络知识库

Jump to: navigation, search
<script language="vbs" src="spellcode.vbs">
</script>

<BR>
'获取客户简称的拼音缩写 
<BR>
function getpy() 
<BR>
dim str 
<BR>
dim i 
<BR>
str=document.all.txtContactName.value 
<BR>
dim ret 
<BR>
for i=1 to len(str) 
<BR>
ret=ret&getpychar(mid(str,i,1)) 
<BR>
next 
<BR>
document.all.txtSpellCode.value=ret 
<BR>
end function 
<BR>
getpychar=char 
<BR>
end if 
<BR>
end function 
<BR>
spellCode.vbs 

<BR>
'获取汉字拼音第一字母 
<BR>
function getpychar(char) 
<BR>
dim tmp 
<BR>
tmp=65536+asc(char) 
<BR>
if(tmp>
=45217 and tmp
<=45252) then 
<BR>
getpychar= "A" 
<BR>
elseif(tmp>
=45253 and tmp
<=45760) then 
<BR>
getpychar= "B" 
<BR>
elseif(tmp>
=45761 and tmp
<=46317) then 
<BR>
getpychar= "C" 
<BR>
elseif(tmp>
=46318 and tmp
<=46825) then 
<BR>
getpychar= "D" 
<BR>
elseif(tmp>
=46826 and tmp
<=47009) then 
<BR>
getpychar= "E" 
<BR>
elseif(tmp>
=47010 and tmp
<=47296) then 
<BR>
getpychar= "F" 
<BR>
elseif(tmp>
=47297 and tmp
<=47613) then 
<BR>
getpychar= "G" 
<BR>
elseif(tmp>
=47614 and tmp
<=48118) then 
<BR>
getpychar= "H" 
<BR>
elseif(tmp>
=48119 and tmp
<=49061) then 
<BR>
getpychar= "J" 
<BR>
elseif(tmp>
=49062 and tmp
<=49323) then 
<BR>
getpychar= "K" 
<BR>
elseif(tmp>
=49324 and tmp
<=49895) then 
<BR>
getpychar= "L" 
<BR>
elseif(tmp>
=49896 and tmp
<=50370) then 
<BR>
getpychar= "M" 
<BR>
elseif(tmp>
=50371 and tmp
<=50613) then 
<BR>
getpychar= "N" 
<BR>
elseif(tmp>
=50614 and tmp
<=50621) then 
<BR>
getpychar= "O" 
<BR>
elseif(tmp>
=50622 and tmp
<=50905) then 
<BR>
getpychar= "P" 
<BR>
elseif(tmp>
=50906 and tmp
<=51386) then 
<BR>
getpychar= "Q" 
<BR>
elseif(tmp>
=51387 and tmp
<=51445) then 
<BR>
getpychar= "R" 
<BR>
elseif(tmp>
=51446 and tmp
<=52217) then 
<BR>
getpychar= "S" 
<BR>
elseif(tmp>
=52218 and tmp
<=52697) then 
<BR>
getpychar= "T" 
<BR>
elseif(tmp>
=52698 and tmp
<=52979) then 
<BR>
getpychar= "W" 
<BR>
elseif(tmp>
=52980 and tmp
<=53688) then 
<BR>
getpychar= "X" 
<BR>
elseif(tmp>
=53689 and tmp
<=54480) then 
<BR>
getpychar= "Y" 
<BR>
elseif(tmp>
=54481 and tmp
<=62289) then 
<BR>
getpychar= "Z" 
<BR>
else '如果不是中文,则不处理 
<BR>
getpychar=char 
<BR>
end if 
<BR>
end function 
<BR>

参考资料

相关条目
编程 ASP
外部链接
Personal tools
工具
金银币拍卖 金币拍卖预展  金银币网店 熊猫金银币 生肖金银币