vb 编一函数,统计字符串中汉字的个数 求完整代码
1个回答
展开全部
Private Function RegExpTest(strng As String) As Long
Dim Re As Object
Dim Rec As Object
Set Re = CreateObject("VBScript.RegExp")
Re.Global = True
Re.Pattern = "[\u4e00-\u9fa5]"
Set Rec = Re.Execute(strng)
RegExpTest = Rec.Count
End Function
Private Sub Form_Load()
Dim a As String
a = "我,伍慧手我腔嫌是坏蛋3号"
MsgBox "字符串:" & vbCrLf & a & vbCrLf & "含有中文字符:" & RegExpTest(a) & "个碧旦"
End Sub
Dim Re As Object
Dim Rec As Object
Set Re = CreateObject("VBScript.RegExp")
Re.Global = True
Re.Pattern = "[\u4e00-\u9fa5]"
Set Rec = Re.Execute(strng)
RegExpTest = Rec.Count
End Function
Private Sub Form_Load()
Dim a As String
a = "我,伍慧手我腔嫌是坏蛋3号"
MsgBox "字符串:" & vbCrLf & a & vbCrLf & "含有中文字符:" & RegExpTest(a) & "个碧旦"
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |