在text3中有70000多行 逐行读取判断其长度跟是否包含.com 符合就输出到另一text里
我这样写了 但太慢 循环要1个多小时。。
麻烦有高手优化下。。
arr = Split(Text3.Text, vbCrLf)
hang = (UBound(arr))
MsgBox hang
Label4.Caption = hang
For L = 0 To hang
st = Split(Text3.Text, vbCrLf)(L)
If st = "" Then Exit For
If RealLen(Mid(st, 1, InStr(1, st, ".") - 1)) < 6 And InStr(st, ".com") > 0 Then
Text1.Text = Text1.Text & st & vbCrLf
End If
Label5.Caption = L
DoEvents
Next L
Function RealLen(txt)
Dim x, y, i
x = Len(txt)
y = 0
For i = 1 To x
If Asc(Mid(txt, i, 1)) < 0 Or Asc(Mid(txt, i, 1)) > 255 Then
y = y + 2 '双字节
Else
y = y + 1 'ascii码字符
End If
Next
RealLen = y
End Function
能给段代码不? 谢谢
追答我对VB.net 不是特别熟。这是在网上找的。
Sub Main()
Dim re As Regex = New Regex(".com")
Dim mc as MatchCollection = re.Matches(sourcestring)
Dim mIdx as Integer = 0
For each m as Match in mc
For groupIdx As Integer = 0 To m.Groups.Count - 1
Console.WriteLine("[{0}][{1}] = {2}", mIdx, re.GetGroupNames(groupIdx), m.Groups(groupIdx).Value)
Next
mIdx=mIdx+1
Next
End Sub
那看不到状态的输出了吧?