Article ID: 140354
Article Last Modified on 1/8/2003
Private Sub Command1_Click ()
Dim string1 As String * 20
Dim string2 As String * 4
Dim i As Integer
Open "test.dat" For Output As #1
For i = Asc("A") To Asc("Z")
Print #1, Chr$(i);
Next i
Close #1
Open "test.dat" For Binary As #1
Do
'If (Loc(1) + 20) > LOF(1) Then Exit Sub
string1 = Input$(20, 1)
Debug.Print string1
'If (Loc(1) + 4) > LOF(1) Then Exit Sub
string2 = Input$(4, 1)
Debug.Print string2
Loop Until EOF(1)
Close #1
End Sub
string1 = "ABCDEFGHIJKLMNOPQRST"
string2 = "UVWX"
string1 = "YZ "
string2 = " "
Uncommenting the commented lines in the above procedure causes Visual
Basic to check whether the next call to Input$ will read past the end of
the file, avoiding the error. Additional code would be required to mimic
exactly the functionality of Visual Basic 3.0. After determining that
the next call to Input$ would read past the end of file, this new code
would call Input$, but only read up to the end of file, not past it.
Since this isn't implemented in the example code, the procedure exits
before the last two characters ("YZ") are read.142246 BUG: Sequential File I/O Does Not Handle Embedded Nulls
Additional query words: buglist4.00 4.00 vb4all vb4win
Keywords: kbbug KB140354