Quote (Chesse @ Nov 16 2013 10:31pm)
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim x, y, z As Double
Dim sr As IO.StreamReader = IO.File.OpenText("DATA.TXT")
y = 0
x = CDbl(sr.ReadLine)
Do While x < 5
If x = 4 Then
sr.Close()
sr = IO.File.OpenText("DATA.TXT")
End If
z = x + y
x = CDbl(sr.ReadLine)
y = CDbl(sr.ReadLine)
Loop
txtBox.Text = CStr(z)
sr.Close()
End Sub
The nine lines of the file DATA.TXT contain the following data:3, 4, 6, 8, 1, 2, 5, 9, 3.
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim letter As String
Dim sr As IO.StreamReader = IO.File.OpenText("DATA.TXT")
Do While sr.Peek <> -1
letter = sr.ReadLine
txtBox.Text &= letter
Do While (sr.Peek <> -1) And (letter <> "*")
letter = sr.ReadLine
Loop
Loop
End Sub
Assume the 12 lines of the file DATA.TXT contain the following data: a, b, c, *, d, *, e, f, g, h, *, i.
This is my first time using visual basics so I am not familiar with some of these terms.
For instance, what is sr and the express "<>" ??
sr is just a variable you defined as an instance of StreamReader
<> is "not equal"
just run your program to see the output
This post was edited by carteblanche on Nov 16 2013 09:16pm