Tony C
Tony C

Reputation: 568

Quick fix, Read text in a text box?

I have a simple text reading code for Visual Basic:

Dim fileReader As String
fileReader = My.Computer.FileSystem.ReadAllText("C:\test.txt")
MsgBox(fileReader)

I have used this in the past, but I usually make the text display in a text box. I know this is sort of a "newb" question but I can't remember how to display the text in a textbox. If you guys could help me out that would be great!

Upvotes: 0

Views: 937

Answers (2)

Dostee
Dostee

Reputation: 744

myTextBox.text = fileReader

Upvotes: 1

Reed Copsey
Reed Copsey

Reputation: 564323

You'd just do:

 textBox1.Text = fileReader

This puts the contents of the string "fileReader" into the TextBox's Text, provided you're doing this from within your Form, and you have a text box on the form named "textBox1".

Also, make sure that your text box is set to be a multi line textbox, if your file has more than a single line within it.

Upvotes: 1

Related Questions