londonkiwi
Programmer
All I want to do is count how many line there are between the block (defined by the lines 21 to 23) and write that value into a new line eg PLINE (500). Can someone please show me how to write the Do..Until Loop correctly??
Thanks for your help!!
This is the MIF file
21 1156 1157 2629974 6611014
22 1156 1157 2629979 6611013
22 1156 1157 2629980 6611013
23 1156 1157 2629993 6610897
21 1158 1159 2630065 6611130
23 1158 1159 2630080 6611298
I want to see this
Pline (4)
.......lines of other data
Pline (2) etc
Private Sub Command5_Click()
Dim lCounter As Long
Dim lLine As Long
Dim sLine As String
Dim sNewLine As String
Dim FileNumRead As Integer
Dim FileNumWrite As Integer
Dim lData1 As Long
Dim I As Integer
Dim sFileName As String
sFileName = App.Path & "\Ex_Track_Crd.crd"
Dim sNewFile As String
sNewFile = App.Path & "\Crd_Mif.mif"
FileNumRead = FreeFile
Open sFileName For Input As #FileNumRead
FileNumWrite = FreeFile
Open sNewFile For Output As #FileNumWrite
lCounter = 0
lLine = 0
Line Input #FileNumRead, sLine ' get first line of data
Do Until (Left(sLine, 2)) = "21" Or EOF(FileNumRead)
Line Input #FileNumRead, sLine
Loop
Line Input #FileNumRead, sLine
Do Until EOF(FileNumRead)
' code here to process line of data, setting sData1-sData5
I = 1
Do Until Mid(sLine, I, 1) = " " 'find first marking character
lData1 = lData1 & Mid(sLine, I, 1)
I = I + 1
Loop
Do Until lData1 = 23
lCounter = lCounter + 1 ' count the number of lines from "21" to "23"
Loop
Print #FileNumWrite, "Pline" & "(" & lCounter & ""
' write the number of lines
lCounter = 0
Line Input #FileNumRead, sLine ' get next line to see what number to begin output with
lData1 = 0
Loop
Close #FileNumRead
Close #FileNumWrite
MsgBox "Completed Reading Tracks CRD (Ex_Track_crd) and Writing PLINE MIF (crd_mif)"
End Sub [sig][/sig]
Thanks for your help!!
This is the MIF file
21 1156 1157 2629974 6611014
22 1156 1157 2629979 6611013
22 1156 1157 2629980 6611013
23 1156 1157 2629993 6610897
21 1158 1159 2630065 6611130
23 1158 1159 2630080 6611298
I want to see this
Pline (4)
.......lines of other data
Pline (2) etc
Private Sub Command5_Click()
Dim lCounter As Long
Dim lLine As Long
Dim sLine As String
Dim sNewLine As String
Dim FileNumRead As Integer
Dim FileNumWrite As Integer
Dim lData1 As Long
Dim I As Integer
Dim sFileName As String
sFileName = App.Path & "\Ex_Track_Crd.crd"
Dim sNewFile As String
sNewFile = App.Path & "\Crd_Mif.mif"
FileNumRead = FreeFile
Open sFileName For Input As #FileNumRead
FileNumWrite = FreeFile
Open sNewFile For Output As #FileNumWrite
lCounter = 0
lLine = 0
Line Input #FileNumRead, sLine ' get first line of data
Do Until (Left(sLine, 2)) = "21" Or EOF(FileNumRead)
Line Input #FileNumRead, sLine
Loop
Line Input #FileNumRead, sLine
Do Until EOF(FileNumRead)
' code here to process line of data, setting sData1-sData5
I = 1
Do Until Mid(sLine, I, 1) = " " 'find first marking character
lData1 = lData1 & Mid(sLine, I, 1)
I = I + 1
Loop
Do Until lData1 = 23
lCounter = lCounter + 1 ' count the number of lines from "21" to "23"
Loop
Print #FileNumWrite, "Pline" & "(" & lCounter & ""
' write the number of lines
lCounter = 0
Line Input #FileNumRead, sLine ' get next line to see what number to begin output with
lData1 = 0
Loop
Close #FileNumRead
Close #FileNumWrite
MsgBox "Completed Reading Tracks CRD (Ex_Track_crd) and Writing PLINE MIF (crd_mif)"
End Sub [sig][/sig]