'****************************
'* 半形<=>全形 *
'* [NB聯盟] *
'* Writer YuPing *
'****************************
'* 參數說明:
'* str:要轉換的字串
'* flag:標記,為0時半轉全,為非0時全轉半
'* 傳回值類型:字串
'****************************
function DBC2SBC(str,flag)
dim i
if len(str)<=0 then
msgbox '字串參數出錯'
exit function
end if
for i=1 to len(str)
str1=asc(mid(str,i,1))
if str1>0 and str1<=125 and not flag then
dbc2sbc=dbc2sbc&chr(asc(mid(str,i,1))-23680)
else
dbc2sbc=dbc2sbc&chr(asc(mid(str,i,1))+23680)
end if
next
end function
'樣本:
alert(dbc2sbc("AB",1))