TextBox Control
Submitted by joken on Tuesday, November 19, 2013 - 14:38.
One of the most common control used in visual basic is a text box. The main purpose of textbox is that, it allows user to input text information to be used by the program. By default, text box takes a single line of text. But using visual basic, you can set the property to accept a multiple line of text and even with a scroll bar.
This time, open visual basic and create a new project called “Textbox”. Then drag a six text box and six label from the toolbox. And arrange all the objects that look like as shown below.
What we're doing here is a Calculator for Multiplication, Division, Addition and Subtraction, that when the user type the value for the Input 1 and during the encoding the values in Input 2 the program will automatically compute for each operator and display the output in the corresponding text box.
To do this add the following code:
In this code below, we use TextChanged event that triggered when there is any change in the textbox. Then it will automatically compute for our different operators.
When executing the program, it will give an output that look likes as shown below.
- Private Sub txtinput2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtinput2.TextChanged
- 'will do the computation for multiplication
- 'will do the computation for Division
- 'will do the computation for Addition
- 'will do the computation for Subtraction
- End Sub
Add new comment
- 686 views