Option Explicit 'Strict syntax
Dim reg, matches, match, file, max, flag, submatch, fso, temp
Set fso = CreateObject("scripting.filesystemobject")'Create FSO object
Set reg = new regexp 'Create regular expression object
reg.global = True 'Global search
reg.ignorecase = True 'Ignore case
reg.pattern = "CT : *([0-9\-]+) +C" 'Matching pattern string (regular expression)
flag = False 'Mark whether it is the first loop
Set file = fso.opentextfile("1.txt",1)
If Not file.atendofstream Then 'File is not empty
Set matches = reg.execute(file.readall()) 'Execute search
For Each match In matches 'Iterate all matches
For Each submatch In match.submatches 'Iterate matching sub-items (content in parentheses in pattern string)
temp = Int(submatch) 'Transform into positive number
Next
If flag=False Then 'First time direct assignment
max = temp
flag = True
ElseIf max<temp Then 'Comparison assignment later
max = temp
End if
Next
End If
If max>45 And max<90 Then
MsgBox "OK"
Else
MsgBox "NG"
End If
'Release object
Set reg = Nothing
Set fso = Nothing
Recent Ratings for This Post
( 1 in total)
Click for details
| Rater | Score | Time |
| baomaboy |
+11 |
2007-05-13 19:02 |