VB6 正则表达式问题 - 提示无效的过程调用或者参数

PrivateSubCommand1_Click()DimsAsString'字符串DimpAsString'正则表达式DimrAsString'要替换的字符串s=Tex... Private Sub Command1_Click()

Dim s As String '字符串
Dim p As String '正则表达式
Dim r As String '要替换的字符串
s = Text1.Text
p = "([0-9]{4}).([0-9]).([0-9]{2})"
Dim re1 As RegExp
Dim mhs1 As MatchCollection
Dim mh1 As Match
Set re1 = New RegExp
re1.IgnoreCase = True
re1.Global = True
re1.Pattern = p
Set mhs1 = re1.Execute(s)
Set mh1 = mhs1(0)
r = mh1.SubMatches(0) & ".0" & mh1.SubMatches(1) & "." & mh1.SubMatches(2)
Text2.Text = r
'下一遍
s = Text2.Text
p = "([0-9]{4}).([0-9]{2}).([0-9])"
Dim re2 As RegExp
Dim mhs2 As MatchCollection
Set re2 = New RegExp
re2.IgnoreCase = True
re2.Global = True
re2.Pattern = p
Set mhs2 = re2.Execute(s)
r = mh2.SubMatches(0) & "." & mh2.SubMatches(1) & ".0" & mh2.SubMatches(2)
Text2.Text = r
'下一遍
s = Text2.Text
p = "([0-9]{4}).([0-9]).([0-9])"
Dim re3 As RegExp
Dim mhs3 As MatchCollection
Set re3 = New RegExp
re3.IgnoreCase = True
re3.Global = True
re3.Pattern = p
Set mhs3 = re3.Execute(s)
r = mh3.SubMatches(0) & ".0" & mh3.SubMatches(1) & ".0" & mh3.SubMatches(2)
Text2.Text = r
End Sub
Set mh1 = mhs1(0) 一行:
实时错误5
无效的过程调用或者参数
展开
 我来答
szqaly
2013-10-04 · TA获得超过1745个赞
知道大有可为答主
回答量:2107
采纳率:77%
帮助的人:1531万
展开全部
这个问题估计是没有匹配项所致,这句前先检查一下mhs1.Count 是否等于0,如是就不必下面的操作了。
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式