
Reading a text file char by char.
Quote:
> Im trying to read a text file character by character
> Here is some code i wrote, it inputs garbage instead of the
> characters. What am i doing wrong?
> Dim achar As String * 1
> Dim aword As String
> CommonDialog1.ShowOpen
> Open CommonDialog1.FileName For Input As #1
> Do While Not EOF(1)
> Input #1, achar
> aword = aword + achar
> If achar = Chr(32) Then
> `its a word do what i will
> End If
> Loop
> Close #1
open yur file in binary mode.
and use Get like this.............
Dim achar As String * 1
Dim aword As String
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Binary As #1
Do While Not EOF(1)
Get #1, , achar 'use Get and note the 2 commas
(there is an implied file postion arg)
aword = aword & achar
If achar = Chr(32) Then
Msgbox aword
End
End If
Loop
Close #1