Text boxes in a user interface are often used to get information from the user, but they can also be used to display values dynamically. The "TextBox.Text" property can be used in Visual Basic to add values to a text box control. The same property can be used to retrieve the content in a text box and use it in your program. It's best to display information through labels, but you can use a text box as well.
Things You'll Need
- Microsoft Visual Basic Express
Launch Microsoft Visual Basic Express, click "New Project..." from the left pane of your computer screen and select "Windows Forms Application." Click "OK."
Double-click "TextBox" from the "Toolbox" pane to add a new text box control to the Form. Double-click "Button" to add a new button.
Double-click "Button1" to create a click event procedure for the button. Inside the click event add the following VB code to display values 1 through 10 divided by commas in the text box control:
Dim myValues(10) As Integer
Dim vCntr As Integer
Me.TextBox1.Text = vCntr
For vCntr = 1 To 10
Me.TextBox1.Text = Me.TextBox1.Text & "," & vCntr
Press "F5" and click "Button1" to display the values in the text box.
- Photo Credit Jupiterimages/Photos.com/Getty Images
How to Display Message in Visual Basic
Visual Basic is a good computer language for beginners. Not only does it have an easy syntax to understand, but Visual Basic...