啟動excel 2003(其它版本請仿照操作),開啟相應的工作表;
執行「工具→巨集→visual basic編輯器」命令(或者直接按「alt+f11」組合鍵),進入visual basic編輯狀態;
執行「插入→模組」命令,插入乙個新模組。再雙擊插入的模組,進入模組**編輯狀
將**輸入其中。 **如下:
function pinyin(p as string) as string
i = asc(p)
select case i
case -20319 to -20284: pinyin = "a"
case -20283 to -19776: pinyin = "b"
case -19775 to -19219: pinyin = "c"
case -19218 to -18711: pinyin = "d"
case -18710 to -18527: pinyin = "e"
case -18526 to -18240: pinyin = "f"
case -18239 to -17923: pinyin = "g"
case -17922 to -17418: pinyin = "h"
case -17417 to -16475: pinyin = "j"
case -16474 to -16213: pinyin = "k"
case -16212 to -15641: pinyin = "l"
case -15640 to -15166: pinyin = "m"
case -15165 to -14923: pinyin = "n"
case -14922 to -14915: pinyin = "o"
case -14914 to -14631: pinyin = "p"
case -14630 to -14150: pinyin = "q"
case -14149 to -14091: pinyin = "r"
case -14090 to -13319: pinyin = "s"
case -13318 to -12839: pinyin = "t"
case -12838 to -12557: pinyin = "w"
case -12556 to -11848: pinyin = "x"
case -11847 to -11056: pinyin = "y"
case -11055 to -2050: pinyin = "z"
case else: pinyin = p
end select
end function
function getpy(str)
for i = 1 to len(str)
getpy = getpy & pinyin(mid(str, i, 1))
next i
end function
**輸入完成後,關閉visual basic編輯視窗,返回excel編輯狀態;
自定義函式就可以用了,如:選中a2單元格,輸入公式:=getpy(a2)。
SqlServer 筆記二 獲取漢字的拼音首字母
一 該函式傳入字串,返回資料為 如果為漢字字元,返回該字元的首字母,如果為非漢字字元,則返回本身。二 用到的知識點 漢字對應的unicode值,漢字的排序規則。三 資料庫函式 create function getinitialletter chinesestring nvarchar 4000 r...
獲取拼音碼的儲存過程,首拼
create function f getpy str nvarchar 4000 returns nvarchar 4000 asbegin declare py table ch char 1 hz1 nchar 1 collate chinese prc cs as ks ws,hz2 nch...
利用反射獲取類的所有字段
以下是利用反射獲取類refpoint中所有的字段。一,refpoint類 public class refpoint public class class02 二,列印出所有類refpoint中的所有字段 refpoint refpoint01 new refpoint 3 type typeobj...