求问vb6.0中如何实现文本框中的段落数,字符数,字母数,和数字个数的统计
2个回答
展开全部
'用正规表达式对象操作
'首选引用 Microsoft VBScript Regular Expressions 5.5 库
'放1个文本框,4个按钮
Dim regEx As New RegExp
Private Sub Form_Load()
regEx.Global = True
regEx.MultiLine = True
regEx.IgnoreCase = True
End Sub
Private Sub Command1_Click() '统计行数
regEx.Pattern = "$"
MsgBox "行数:" & regEx.Execute(Text1.Text).Count
End Sub
Private Sub Command2_Click() '统计数字
regEx.Pattern = "\d"
MsgBox "数字:" & regEx.Execute(Text1.Text).Count
End Sub
Private Sub Command3_Click() '统计字母
regEx.Pattern = "[a-z]"
MsgBox "字母数:" & regEx.Execute(Text1.Text).Count
End Sub
Private Sub Command4_Click() '统计总字符数
MsgBox "字符数:" & Len(Text1.Text)
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询