Easy coding for the number is even or odd in Visual Basic

If are you looking for a simple program that will display even and odd numbers in vb6 then this post will helpful for you. Most beginner programmers are confused about how to write this type program in simple ways therefore here we are given understandable coding for creating this program. I hope you will get the proper solution and solve your problem, so without wasting time let's start writing an answer.

This program displays the even number in one Listbox and the odd value in another Listbox. I know this is the basic program but most of the time beginners are confused about how to solve even-odd number programs in vb6.0. If you do have not any idea about how to write code for this question then don't worry here I have given an easy source code due to that you can create the program in the best way. for a better understanding of the answer follow the below-given points:

Steps for writing even or odd program in visual basic:

1. First Design the form as given.
2. Draw three command buttons.
3. After that take three list boxes for displaying the results.


number is even or in visual basic

Source code for displaying even and odd numbers in vb

Dim n, num(5) As Integer
Private Sub accept1_Click()
For cnt = 1 To 5 Step 1
num(cnt) = InputBox("Enter the number")
List1.AddItem num(cnt)
Next cnt
accept1.Enabled = False
End Sub

Private Sub even1_Click()
For cnt = 1 To 5 Step 1
If num(cnt) Mod 2 = 0 Then
List2.AddItem num(cnt)
End If
Next cnt
End Sub

Private Sub odd1_Click()
For cnt = 1 To 5 Step 1
If num(cnt) Mod 2 <> 0 Then
List3.AddItem num(cnt)
End If
Next cnt
End Sub

If you want to download this source code then you can comment to me or you can send a message to download it here.

How to work this program?

To execute this coding follow the following steps:
1. By clicking on accept button user can enter the numbers through the input box.
2. after that click on an even button for checking number is even.
3. And press an odd button to check the number is odd.

An output of the program:


even or odd program in vb


After checking the result the output is:

vb even or odd program


I hope you understood the program and got the proper solution to your question. If this is helpful for you then you can share this program with your friends.

Post a Comment

10 Comments

  1. Thanks! finaly I have got perfect and easy coding of even or odd number in vb.

    ReplyDelete
  2. Wow! Best coding for even odd program in visual basic. Thanx

    ReplyDelete
  3. Awesome! Nice coding for vb even odd program. Thank you. Plz upload more easy article.

    ReplyDelete
  4. Ok, i will provide more easy solution for every visual basic programs.

    ReplyDelete
  5. Very nice blog ... Very easy coding for even odd program .

    ReplyDelete
  6. Nice is it very helpful for me
    Keep trying

    ReplyDelete
  7. Write a program in VB to find out whether a given number is EVEN or ODD



    ReplyDelete
    Replies
    1. Thanks for respond to me. i have given your solution in proper way. check this article for find given number is even or odd program in vb6.
      https://allvbprograms.blogspot.com/2020/10/given-number-is-even-or-odd-in-visual-basic-6.html

      Delete
  8. Super helpful. So easy to understand. Post more please

    ReplyDelete