It depends on how the files are going to stored. Random access, Sequential Files??
Line Input or Input could be used.
Printable View
It depends on how the files are going to stored. Random access, Sequential Files??
Line Input or Input could be used.
VB Code:
Dim strLine As String Open "C:\Temp\test.txt" For Input As #1 Do While Not EOF(1) Line Input #1, strLine txtDisplay.Text = txtDisplay.Text & strLine & vbCrLf Loop Close #1
Make sure you set the MultiLine property of the textbox to True!
Thanks for your replies guys.
The file is stored as a normal text file. The code from ae_jester is like the one i used before accept for the "Line" in front of "Input". I tried it but it still did not work.
vbBoy.
What is the exact problem you are facing now?
Thanks for the reply mendhak.
The exact problem is that I have this text file that I would like to display its contents line by line on a text box. I could display it but the lines follow each other directly and not line by line as it is stored in the text file.
vbBoy.
What is the delimiter that separates each 'line' then ?
If it is not a CR/FL then there must be a character that delimits
each line/record/field.
Let me know the chars, and I'll send you a routine to read the file, and 'unpack' the input string and then manipulate as individual lines/records.
i.e. is the record
1) "ID", "Field1" , "Field2", "Field3"
2) 123, "aaa" , "bbb", "ccc"
3) 456, "ddd", "eee", "fff"
4) etc,
or
1)123, "aaa" , "bbb", "ccc"<DELIM CHAR>456, "ddd", "eee", "fff" etc,
Hello johnLoveless...
There is no delimiter that seperates the lines. The text looks like this:
___________________________________________________
How are you?
What are doing tonight? Will you like to go to the mcdonalds?
Say at 08:00 hours.
___________________________________________________
Thanks
vbBoy
Dim strLine As String
Open "C:\Temp\test.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, strLine
txtDisplay.Text = txtDisplay.Text & strLine & Chr(13) & Chr(10)
Loop
Close #1
=-=-=-=-=-=-=-=-=-=-=-=-=-=-
I've used the original code used, then changed the vbCrLf (I think?) to Chr(13) and Chr(10) which is a Carriage return and line feed...
vBoy,
Post (attach) the textfile in question as the Line Input
examples should have worked.
Thanks for your reply guys....
The code from Cytharni works just as I wanted.
vbBoy
Have a look at the attached and let me know what else is needed
and/or what is wrong etc.