BlueIshDan
☠
- Local time
- Yesterday, 20:02
- Joined
- May 15, 2014
- Messages
- 1,122
Whatcha need to know in VB?
:banghead:You then use If left(textline,x) = "Asomething" then....
x would depend on what defines your line, if it is A12, then obviously x would be 3
To find out what line you are at and use functions like Left, Right and Mid to extract the information you need from the line ....
:banghead:I assume the first four chars of any line will identify the "line type"
I.e. on line A040 you know you can find the airline name from character 11 to 24
Research Line Input or is it Input line, that should get you started.
Well reading each line is atleast the starting point, walk before you can run.
Once you can read each line, you can then handle the different lines using an
etc...Code:If Left(yourLine,3) = "A12" then 'handle the A12 line endif If Left(yourLine,3) = "A14" then 'handle the A14 line endif
hi BlueIshDan,
Dim TextLine As String
FileOpen(1, "c:\test.txt", OpenMode.Input)
While Not EOF(1)
TextLine = LineInput(1)
MsgBox(TextLine)
End While
FileClose(1)
In the above code i need to read line number 9 and pick characters from 4 to 18 and display it in a text box(for now). Similarly i need to do for the other lines with different character count. if i could get the code for Line 9 then i guess i can do for the rest.
Dim TextLine As String
FileOpen(1, "c:\test.txt", OpenMode.Input)
While Not EOF(1)
TextLine = LineInput(1)
MsgBox("'" & Left(TextLine,3) & "' are the first 3 characters" )
MsgBox("'" & Mid(TextLine,3,3) & "' are the next 3 characters" )
MsgBox("'" & mid(TextLine,20,10) & "' 20th to 30th characters" )
MsgBox("'" & Right(TextLine,3) & "' are the last 3 characters" )
End While
FileClose(1)
Dim TextLine
Open "TESTFILE" For Input As #1 ' Open file.
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, TextLine ' Read line into variable.
Debug.Print TextLine ' Print to the Immediate window.
Loop
Close #1 ' Close file.
Dim TextLine as String 'Idiots at M$ never add AS ...
Open "TESTFILE" For Input As #1 ' Open file.
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, TextLine ' Read line into variable.
'Slightly more friendly to have only one box instead of 4
MsgBox ("'" & Left(TextLine, 3) & "' are the first 3 characters" & Vbnewline & _
"'" & Mid(TextLine, 3, 3) & "' are the next 3 characters" & Vbnewline & _
"'" & Mid(TextLine, 20, 10) & "' 20th to 30th characters" & Vbnewline & _
"'" & Right(TextLine, 3) & "' are the last 3 characters"
Debug.Print TextLine ' Print to the Immediate window.
Loop
Close #1 ' Close file.
use my function for reading the lines...
Compile error:synatax error
Option Compare Database
Private Sub Command0_Click()
Dim TextLine As String 'Idiots at M$ never add AS ...
Open "c:\test.txt" For Input As #1 ' Open file.
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, TextLine ' Read line into variable.
'Slightly more friendly to have only one box instead of 4
MsgBox ("'" & Left(TextLine, 3) & "' are the first 3 characters" & Vbnewline & _
"'" & Mid(TextLine, 3, 3) & "' are the next 3 characters" & Vbnewline & _
"'" & Mid(TextLine, 20, 10) & "' 20th to 30th characters" & Vbnewline & _
"'" & Right(TextLine, 3) & "' are the last 3 characters"
Debug.Print TextLine ' Print to the Immediate window.
Loop
Close #1 ' Close file.
End Sub
Hi namliam,
i get the below error when clicking on the button in the form
I've pasted the below code in the On Click event of the button propertyCode:Compile error:synatax error
Code:Option Compare Database Private Sub Command0_Click() Dim TextLine As String 'Idiots at M$ never add AS ... Open "c:\test.txt" For Input As #1 ' Open file. Do While Not EOF(1) ' Loop until end of file. Line Input #1, TextLine ' Read line into variable. 'Slightly more friendly to have only one box instead of 4 MsgBox ("'" & Left(TextLine, 3) & "' are the first 3 characters" & Vbnewline & _ "'" & Mid(TextLine, 3, 3) & "' are the next 3 characters" & Vbnewline & _ "'" & Mid(TextLine, 20, 10) & "' 20th to 30th characters" & Vbnewline & _ "'" & Right(TextLine, 3) & "' are the last 3 characters"[COLOR="Red"])[/COLOR] Debug.Print TextLine ' Print to the Immediate window. Loop Close #1 ' Close file. End Sub