VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This code is for checking whether a number is even or odd.

by ACMOA (7 Submissions)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 18th October 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This code is for checking whether a number is even or odd.

API Declarations


DIM NUM2 AS Integer 'Second way to do it
DIM NUM3 AS Integer 'Third way to do it

Rate This code is for checking whether a number is even or odd.




NUM = InputBox ("Input the number to check:")
If NUM Mod 2 = 0 Then
 Print "Even"
Else
 Print "Odd"
End If

'Second way

NUM2 = InputBox("Input the number:")
If NUM2 / 2 = Math.Round(NUM2 / 2) Then
 Print "Even"
Else
 Print "Odd"
End If

'Third way

NUM3 = InputBox("Input the Number:")
If NUM3 / 2 = Int(NUM3 / 2) Then
 Print "Even"
Else
 Print "Odd"
End If

Download this snippet    Add to My Saved Code

This code is for checking whether a number is even or odd. Comments

No comments have been posted about This code is for checking whether a number is even or odd.. Why not be the first to post a comment about This code is for checking whether a number is even or odd..

Post your comment

Subject:
Message:
0/1000 characters