|
-
Oct 16th, 2000, 06:10 AM
#1
Thread Starter
Member
I've look and tried - can you help???
Can you masters tell me a) what I'm doing wrong b) how to fix it and c) how to start a new line when a new day is found:
Sample of Raw Data
22:31:23 04/10/00 AB 1
23:03:56 04/10/00 BA 2
23:04:38 04/10/00 AB 5
23:08:49 04/10/00 AB 1
05:31:38 05/10/00 BA 8
06:34:46 05/10/00 AB 10
06:43:53 05/10/00 AB 1
07:11:52 05/10/00 AB 1
result could be:
04/10/00,AB,6(the time),0023,0045,0444,5500,etc up to 13 of them
etc
Private Sub proc_finMC_Click()
Dim ab1_Count, ab2_Count, ab3_Count, ab4_Count, ab5_Count, ab6_Count As Long
Dim lLine As Long
Dim FileNumRead As Integer
Dim FileNumWrite As Integer
Dim sLine As String
Dim sFileName As String
sFileName = App.Path & "\MCexport.txt"
Dim sNewFile As String
sNewFile = App.Path & "\MCFin_Proc.txt"
FileNumRead = FreeFile
Open sFileName For Input As #FileNumRead
FileNumWrite = FreeFile
Open sNewFile For Output As #FileNumWrite
Do Until EOF(FileNumRead)
Line Input #FileNumRead, sLine
Loop
ab1_Count = 0: ab2_Count = 0: ab3_Count = 0: ab4_Count = 0: ab5_Count = 0: ab6_Count = 0
Do While Trim(Left(sLine, 2)) >= "0" And Trim(Left(sLine, 2)) >= "6" 'time btw xx-xx hrs
If Mid(sLine, 19, 2) = "AB" Then ' AtoB
If Trim(Mid(sLine, 22, 2)) = "1" Then 'Class = 1
ab1_Count = ab1_Count + 1
ElseIf CStr(Trim(Mid(sLine, 22, 2))) = "2" Then 'Class = 2
ab2_Count = ab2_Count + 1
ElseIf Trim(Mid(sLine, 22, 2)) = "3" Then 'Class = 3
ab3_Count = ab3_Count + 1
ElseIf Trim(Mid(sLine, 22, 2)) = "4" Then 'Class = 4
ab4_Count = ab4_Count + 1
ElseIf Trim(Mid(sLine, 22, 2)) = "5" Then 'Class = 5
ab5_Count = ab5_Count + 1
Else: 'Class = 6 or something else
ab6_Count = ab6_Count + 1
End If
End If
Loop
Print #FileNumWrite, "AB" & "," & ab1_Count & "," & ab2_Count & "," & ab3_Count & "," & ab4_Count & "," & ab5_Count & "," & ab6_Count
Close #FileNumRead
Close #FileNumWrite
MsgBox "Completed"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|