top of page

Visual Basic [5] Tutorial Blog :


Lesson 5: Working with Controls :

In previous lesson, you have learned how to write simple Visual Basic 2013 code. In this lesson, you will learn how to work with some common controls and write codes for them. Some of the common controls are label, text box, button, list box and combo box. However, in this lesson, you will only deal with the text box and the label, you shall learn how to work other controls in later lessons. 5.1 Text Box The following program will add the value in text box 1 and 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 The output window: Text box is the standard control for receiving input from the user.

It can also be used to display the output. It can only handle string (text) and numeric data but not images or pictures. By the way, a string in a text box can be converted to a numeric data by using the function Val(text). The following example illustrates a simple program that processes the input from the user. Example 5.1 In this program, you add two text boxes and a button on the form. The two text boxes are used to accept inputs from the user .

Besides, a button is also programmed to calculate the sum of the two numbers using the plus operator. The value enter into a text box is stored using the syntax Textbox1.Text , where Text is the one of the properties of text box.

Press Icon below for pdf.


Featured Posts
Check back soon
Once posts are published, you’ll see them here.
Recent Posts
Archive
Search By Tags
No tags yet.
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square
bottom of page