Private Sub cmdValidate_Click()
Const ForReading = 1, ForWriting = 2
Dim RawdataStr As String
Dim RawStream
Dim AllTotal As Integer
'initialize all total
AllTotal = 0
' SURE IT WILL NOT EXCEED AN INTEGER VALUE ???
Open "a:\text.txt" For Input As #1
Do Until EOF(1)
DoEvents
Line Input #1, RawdataStr
If InStr(RawdataStr, " 774 ") = 0 Then
'If 774 found on a line
'add to all total the values
AllTotal = AllTotal + Mid(RawdataStr, 25, 4) 'eg output = 0101
AllTotal = AllTotal + Mid(RawdataStr, 29, 4) '0000
AllTotal = AllTotal + Mid(RawdataStr, 33, 4) '1516
AllTotal = AllTotal + Mid(RawdataStr, 37, 4) '1771
AllTotal = AllTotal + Mid(RawdataStr, 41, 4) '9009
AllTotal = AllTotal + Mid(RawdataStr, 45, 4) '1111
AllTotal = AllTotal + Mid(RawdataStr, 49, 4) '1122
AllTotal = AllTotal + Mid(RawdataStr, 53, 4) '0000
AllTotal = AllTotal + Mid(RawdataStr, 57, 4) '0000
AllTotal = AllTotal + Mid(RawdataStr, 61, 4) '7878
MsgBox AllTotal & ": is the total amount"
' commented the End part , this stops your program
' End
'or use action_sa his method, replying same time
'For intStart = 25 To 61 Step 4
' AllTotal = AllTotal + Mid$(RawdataStr, intStart, 4)
'Next
End If
Loop
Close #1
End Sub