Excel实例下载
  VBA  应用教程
    数据库SQL知识
设为首页
提取中文字串的拼音首字母
作者:juejue | 来源:网络转摘 | 时间:2006-03-29 | 阅读权限:游客 | 会员币:0 | 【

一个自定义函数,可提取中文字串中每个字符的拼音首字母,忽略字串中的英文字母和标点,阿拉伯数字,空格等。
附件中有使用范例。
已发现的缺点:不能识别多音字,比如 “单”有"shan、dan"两种读音,其只能识别一种;
到底能识别多少中文字,我也不清楚。

Function HYPY(myStr As String) As String
    Dim L As Integer, i As Integer
    Dim GetPY As String, N As String
    On Error Resume Next
   
   myStr = StrConv(myStr, vbNarrow)
    L = Len(myStr)
   
   For i = 1 To L
      If Asc(Mid(myStr, i, 1)) > 0 Or Err.Number = 1004 Then N = ""
      N = Application.WorksheetFunction.VLookup(Mid(myStr, i, 1), _
      [{"吖","A";"八","B";"嚓","C";"咑","D";"鵽","E";"发","F";"猤","G";"铪","H";"夻","J";"咔","K";"垃","L";"嘸","M";"旀","N";"噢","O";"妑","P";"七","Q";"囕","R";"仨","S";"他","T";"屲","W";"夕","X";"丫","Y";"帀","Z"}], 2)
      GetPY = GetPY & N
   Next i
  
   HYPY = GetPY
End Function
文章录入:admin | 浏览次数:
相关评论(以下网友评论只代表其个人观点,不代表Excel吧的观点或立场)
相关信息
相关文章
  • 没有相关文章

关于本站 | 留言本站 | 友情连接 | 后台管理
Copyright © 2005 - 2008 Excel吧 Inc. All Rights Reserved.
HxCms Ver9.0  闽ICP备06001689号
关闭此窗口