会员登录 - 用户注册 - 网站地图 Office中国(office-cn.net),专业Office论坛
当前位置:主页 > 技巧 > Access技巧 > 编程心得绝招 > 实际编程 > 正文

用VBA统计字符串中的中文字个数

时间:2006-03-19 22:25 来源:原创 作者:朱亦文 阅读:
用VBA统计字符串中的中文字个数


' 统计中文字的个数
' 作者:朱亦文
' 日期:2006.01.05

Function CountZh(ByVal sZh As String) As Integer
    Dim re As New RegExp
    Dim matches As MatchCollection
    
    re.Pattern = "[\u4e00-\u9fa5]"
    re.Global = True
    re.IgnoreCase = True
    Set matches = re.Execute(sZh)
    
    CountZh = matches.Count
    Set re = Nothing
End Function

请引用Microsoft VBScript Regular Express 5.5。

(责任编辑:admin)

顶一下
(0)
0%
踩一下
(0)
0%
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价: