|
-
Jul 28th, 2011, 05:12 PM
#3
Thread Starter
Lively Member
Re: Help! Vb.net Reading a text file line by line
 Originally Posted by .paul.
here's how. on load it reads your text file into a string array, then displays the lines 1 by 1 as you click the button:
vb Code:
Public Class Form1
Dim lines() As String
Dim index As Integer = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lines = IO.File.ReadAllLines("filename.txt")
End Sub
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
TextBox1.Text &= lines(index) & Environment.NewLine
index += 1
If index > lines.GetUpperBound(0) Then button1.Enabled = False
End Sub
End Class
thank you but it did not work as i intended it did not display the second part it only displayed the first part.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|