本帖最后由 pcl_test 于 2015-11-8 09:59 编辑
- Dim arr()
- i = 0
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set f = fso.OpenTextFile("测试.txt",1)
- Do While f.AtEndOfStream <> True
- str = f.ReadLine
- GetZ(str)
- Loop
- f.Close
- '调用Excel函数
- Set objExcel= CreateObject("Excel.Application")
- MsgBox "最大"&objExcel.Max(arr)&vbCrLf&"最小"&objExcel.Min(arr)
-
- Function GetZ(str)
- Set regEx = New RegExp
- regEx.Pattern = "\bZ(-?\d+\.?\d*)"
- regEx.Global = True
- If regEx.Test(str) Then
- Set Matches = regEx.Execute(str)
- For Each Match in Matches
- ReDim Preserve arr(i)
- arr(i) = CDbl(Match.SubMatches(0))
- i = i+1
- Next
- End If
- End Function
复制代码
|