4.1 TextBox
TextBox is the standard control for accepting inputs from the user as well as to display the outputs. It can handle string and numeric data but not images or pictures. String in a TextBox can be converted to numeric data by using the function Val(text). The following example illustrates a simple program that processes the input from the user.
Example 4.1 Adding two numbers
In this program, add two text boxes and a button on the form. The two text boxes are for accepting inputs from the user. Besides that, we program the button to calculate the sum of the two numbers using the plus operator. The value in a text box is stored using the syntax TextBox1.Text , where Text is one of the properties of TextBox.
The following code will add the value in TextBox1 and the value in TextBox2 and displays the sum in a message box. The runtime interface is illustrated in Figure 4.1.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click |
Figure 4.1
After clicking the Add button, you will obtain the answer in a message box, as shown in Figure 4.2.
Figure 4.2
0 Comments
Thanks for your comment.
i will reply you soon.