How to Increment the Value of a Variable in Vb.Net

Written by keith perry
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Increment the Value of a Variable in Vb.Net
Incrementing variables is a key part of looping structures. (Creatas/Creatas/Getty Images)

Incrementing variables in a programming language is one of the first tasks you will be required to learn. When writing your programs in Visual Basic .Net, incrementing the integer data type will be necessary. Controlling of loops is a common use of the variable incrementing, and keeping count of items in your program is another. Use your imagination when coding to solve problems using variables that you increment by 1 or more.

Skill level:

Other People Are Reading

Things you need

  • Microsoft Visual Basic 2003 or later

Show MoreHide


  1. 1

    Click the "Start" icon located on the Windows taskbar and select "Visual Basic."

  2. 2

    Select "File" and "New Project" from the Visual Basic taskbar.

  3. 3

    Select the "Windows Form Application" icon and click the button labelled "OK."

  4. 4

    Select the "Button" icon located in the "Tool Box" window. Click in the window labelled "Form1" and draw a button control.

  5. 5

    Double-click on the button labelled "Button1" to open the code window for the button control.

  6. 6

    Insert the following text below the line, starting with "Private Sub Button1_Click":

    Dim a As Integer

    a = 0

    While a < 5

       a = a + 1

    End While



  7. 7

    Press the "F5" key to execute the code, and click on the button labelled "Button1." A window will display with the number "5," showing the incremented value of the variable "a." Click the button "OK" to end the program.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.