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

Even or Odd in Visual Basic

carloscarli

Virtual Store Owner
C Rep
0
0
0
Rep
0
C Vouches
0
0
0
Vouches
0
Posts
175
Likes
171
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 100 XP
Introduction:
This tutorial is on how to create a simple tool in Visual Basic to check whether the entered number is even or odd.

Design:
For this program, we need a couple of components;
Button, button1, Begin the checking process.
NumericUpDown, numericUpDown1, Hold the number value.

Button Click:
Once the button is clicked, we first want to create a new integer variable and set it equal to the value of the numericupdown control...

  1. Dim

    num As

    Integer

    = numericUpDown1.Value

Next we want to write a simple if statement using the MOD operator to see if the integer variable, MOD 2, is true or not. If it is, the number is even, otherwise it is false...

  1. If

    ((num Mod

    2) = 0) Then
  2. MsgBox("Even"

    )
  3. Else
  4. MsgBox("Odd"

    )
  5. End

    If

Finished!

 

452,496

332,845

332,853

Top