Ciduletz1983
Active member
Good day. I learn VB.NET alone. No support. Just some dumb tutorials. I can`t understand the meaning of "peek" and " -1 " in this code:
Could someone here explain me ? Please!
VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim FILE_NAME As String = "C:\test.txt"
Dim TextLine As String
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objReader As New System.IO.StreamReader(FILE_NAME)
Do While objReader.Peek() <> -1
TextLine = TextLine & objReader.ReadLine() & vbNewLine
Loop
TextBox1.Text = TextLine
Else
MsgBox("File Does Not Exist")
End If
End Sub
Could someone here explain me ? Please!