In this Lesson, we shall learn how to work with some common controls in Visual Basic 2015. Among the commonly used controls are the label, text box, button, list box, combo box, picture box, timer and more. However, in this Lesson, we shall only deal with the text box and the label. The text box is for accepting input from the user as well as to display the output. It can only handle string (text) and numeric data . String in a text box can be converted to a numeric data by using the function Val(text).
Example 5.1
The following program will add the value in text box 1 and the value in text box 2 and output the sum in a message box.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MsgBox("The sum is "&Val(TextBox1.Text) + Val(TextBox2.Text))
End Sub