• We just launched and are currently in beta. Join us as we build and grow the community.

TextBox Control

walidoxbbn01

DNS Spoofer
W Rep
0
0
0
Rep
0
W Vouches
0
0
0
Vouches
0
Posts
117
Likes
157
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 200 XP
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.

txt1.png

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.

  1. Private

    Sub

    txtinput2_TextChanged(

    ByVal

    sender As

    System.

    Object

    , ByVal

    e As

    System.

    EventArgs

    )

    Handles

    txtinput2.

    TextChanged
  2. 'will do the computation for multiplication
  3. txtmul.

    Text

    =

    Val

    (

    txtinput1.

    Text

    )

    *

    Val

    (

    txtinput2.

    Text

    )
  4. 'will do the computation for Division
  5. txtdiv.

    Text

    =

    Val

    (

    txtinput1.

    Text

    )

    /

    Val

    (

    txtinput2.

    Text

    )
  6. 'will do the computation for Addition
  7. txtadd.

    Text

    =

    Val

    (

    txtinput1.

    Text

    )

    +

    Val

    (

    txtinput2.

    Text

    )
  8. 'will do the computation for Subtraction
  9. txtsub.

    Text

    =

    Val

    (

    txtinput1.

    Text

    )

    -

    Val

    (

    txtinput2.

    Text

    )

  10. End

    Sub

When executing the program, it will give an output that look likes as shown below.
txt2.png


 

452,292

323,526

323,535

Top