vb 獲取字串漢字拼音的首字母

2021-06-04 16:55:21 字數 1710 閱讀 8910

public function pinyin(mystr as string) as string

if len(trim(mystr)) = 0 then

pinyin = ""

exit function

end if

i as long

for i = 1 to len(mystr)

j = asc(mid(mystr, i, 1))

select case j

case -20319 to -20284: pinyin = pinyin + "a"

case -20283 to -19776: pinyin = pinyin + "b"

case -19775 to -19219: pinyin = pinyin + "c"

case -19218 to -18711: pinyin = pinyin + "d"

case -18710 to -18527: pinyin = pinyin + "e"

case -18526 to -18240: pinyin = pinyin + "f"

case -18239 to -17923: pinyin = pinyin + "g"

case -17922 to -17418: pinyin = pinyin + "h"

case -17417 to -16475: pinyin = pinyin + "j"

case -16474 to -16213: pinyin = pinyin + "k"

case -16212 to -15641: pinyin = pinyin + "l"

case -15640 to -15166: pinyin = pinyin + "m"

case -15165 to -14923: pinyin = pinyin + "n"

case -14922 to -14915: pinyin = pinyin + "o"

case -14914 to -14631: pinyin = pinyin + "p"

case -14630 to -14150: pinyin = pinyin + "q"

case -14149 to -14091: pinyin = pinyin + "r"

case -14090 to -13319: pinyin = pinyin + "s"

case -13318 to -12839: pinyin = pinyin + "t"

case -12838 to -12557: pinyin = pinyin + "w"

case -12556 to -11848: pinyin = pinyin + "x"

case -11847 to -11056: pinyin = pinyin + "y"

case -11055 to -10247: pinyin = pinyin + "z"

case -9254: pinyin = pinyin + "z"                ''圳

case -3589: pinyin = pinyin + "q"                ''覃

case -32185: pinyin = pinyin + "c"               ''侴

case else: pinyin = pinyin

end select

next i

end function

獲取字串中的漢字拼音首字母

獲取字串中的漢字拼音首字母 根據修改 可能 比較臃腫,希望有朋友再幫忙改正 返回給定字串的首字母 private string indexcode string indextxt convert.toint16 gb2312bytes 0 160 string.format convert.toin...

獲取字串中的漢字拼音首字母

獲取字串中的漢字拼音首字母 根據程式設計客棧iwebsms archive 2004 09 28 119851.aspx修改 可能 比較臃腫,希望有朋友再幫忙改正 返回給定字串的首字母 private string indexcode string indextxt 得到單個字元的首字母 priva...

sqlserver取字串拼音首字母

sqlserver 使用函式獲取乙個字串的拼音首字母 create function dbo.fn getpinyin str nvarchar max returns nvarchar max as begin declare word nchar 1 py nvarchar max set py...