Hello all, i'd like to know howto read one line (define it to a variable), and then do the next with the string on the next line. thanks guys ^^ :)
Printable View
Hello all, i'd like to know howto read one line (define it to a variable), and then do the next with the string on the next line. thanks guys ^^ :)
Read line from where?
sorry forgot to mention that ^^;
text file
Perhaps the following is what you need:
VB Code:
Dim strLine As String Open "c:\test.txt" For Input As #1 Do While Not EOF(1) Line Input #1, strLine Debug.Print strLine Loop Close #1
not quite, what i meant is to have 2 variables, one for each line, and also howto write not only read :) thanks ^^
I showed one quick technic that could easily be accomodated to suit your need...
Here is another:
VB Code:
Dim strText As String Dim arLines() As String Dim i As Integer Open "c:\test.txt" For Input As #1 'read entire file strText = Input(LOF(1), #1) Close #1 'split text on the carriage return arLines() = Split(strText, vbNewLine) 'loop through array For i = 0 To Ubound(arLines) Debug.Print arLines(i) Next i
To write to a file just open it for Output (to create a brand new or overwrite existing) OR for Append.