English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

How do I get visual Basic .NET to load each line of a saved file into s a separate textbox.

For example, I want to load test.txt which has two lines.
1. This is line one.
2. This is line two.

I want each line to load into a separate textbox. Thank you!

2006-12-30 13:22:36 · 1 answers · asked by stultz_is 2 in Computers & Internet Programming & Design

1 answers

Let's say you have a file named test.txt, and you want to create a form named Form1
in your output. You can do something like this:

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 = objReader.ReadLine()
TextBox1 = New TextBox()
TextBox1.ID = "TextBox1"
TextBox1.Style("Position") = "Absolute"
TextBox1.Style("Top") = "25px"
TextBox1.Style("Left") = "100px"
Form1.Controls.Add(TextBox1)
Loop

Textbox1.Text = TextLine

Else

MsgBox("File Does Not Exist")

End If


(depending on your version of .net, you may need to destroy TextBox1 each
time through the loop before you assign it to a new Textbox.)

2006-12-30 14:17:07 · answer #1 · answered by ♫CuriousC☼ 3 · 0 0

fedest.com, questions and answers