Advertisement
NAK

ReadTextFile

NAK
Jun 21st, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.90 KB | None | 0 0
  1. Imports System.IO
  2.  
  3. Public Class Form1
  4.  
  5.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  6.         Dim w As IO.StreamWriter
  7.         w = My.Computer.FileSystem.OpenTextFileWriter("E:\WillTest.txt", True)
  8.  
  9.  
  10.  
  11.  
  12.         w.WriteLine("Nandhu")
  13.         w.WriteLine("True")
  14.         w.Close()
  15.  
  16.     End Sub
  17.  
  18.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  19.         Dim r As IO.StreamReader
  20.  
  21.         r = My.Computer.FileSystem.OpenTextFileReader("E:\WillTest.txt")
  22.  
  23.         Dim s As String
  24.         ' new code to loop thought the lines of text in your file.....
  25.         Do While r.Peek() >= 0
  26.             s = r.ReadLine()
  27.             If s = "True" Then
  28.                 MessageBox.Show("Success", "Success")
  29.             End If
  30.         Loop
  31.         r.Close()
  32.  
  33.     End Sub
  34. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement