[转帖]将汉字转换为对应拼音头字母
正在做的一套程序中需要一个字母索引,就写了这么个函数,需要的可以参考一下,可能有BUG,没仔细测试(不是太重要的时候用,嘿嘿)
function htop(hz)
dim tmp
if asc(hz) > 0 then
htop = hz
else
tmp = asc(hz)
If tmp >= -20319 And tmp <= -20284 Then
htop = "A"
End If
If tmp >= -20283 And tmp <= -19776 Then
htop = "B"
End If
If tmp >= -19775 And tmp <= -19219 Then
htop = "C"
End If
If tmp >= -19218 And tmp <= -18711 Then
htop = "D"
End If
If tmp >= -18710 And tmp <= -18527 Then
htop = "E"
End If
If tmp >= -18526 And tmp <= -18240 Then
htop = "F"
End If
If tmp >= -18239 And tmp <= -17923 Then
htop = "G"
End If
If tmp >= -17922 And tmp <= -17418 Then
htop = "H"
End If
If tmp >= -17417 And tmp <= -16475 Then
htop = "J"
End If
If tmp >= -16474 And tmp <= -16213 Then
htop = "K"
End If
If tmp >= -16212 And tmp <= -15641 Then
htop = "L"
End If
If tmp >= -15640 And tmp <= -15166 Then
htop = "M"
End If
If tmp >= -15165 And tmp <= -14923 Then
htop = "N"
End If
If tmp >= -14922 And tmp <= -14915 Then
htop = "O"
End If
If tmp >= -14914 And tmp <= -14631 Then
htop = "P"
End If
If tmp >= -14630 And tmp <= -14150 Then
htop = "Q"
End If
If tmp >= -14149 And tmp <= -14091 Then
htop = "R"
End If
If tmp >= -14090 And tmp <= -13319 Then
htop = "S"
End If
If tmp >= -13318 And tmp <= -12839 Then
htop = "T"
End If
If tmp >= -12838 And tmp <= -12557 Then
htop = "W"
End If
If tmp >= -12556 And tmp <= -11848 Then
htop = "X"
End If
If tmp >= -11847 And tmp <= -11056 Then
htop = "Y"
End If
If tmp >= -11055 And tmp <= -10247 Then
htop = "Z"
End If
End If
end function
我想函数怎么用应该不用我说了吧