Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 14th, 2003, 11:20 AM
Registered User
Join Date: Jun 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Test if variable is even or odd number

Hi all
 I'm trying to find an easy way to test if a variable is an even or
odd number.

Dim Count as Integer
Count = 0
  Count = Count + 1
  If Count is even then
     perform function
  End if
Loop until count = 100

Thanks for the help
Reply With Quote
  #2 (permalink)  
Old June 14th, 2003, 12:01 PM
Friend of Wrox
Join Date: Jun 2003
Location: High Wycombe, UK, United Kingdom.
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post

Check out the MOD operator, this will tell you what the remainder is of a operaton so :

if ((x mod 2)=0) then
    x is even
    x is odd
end if
Reply With Quote
  #3 (permalink)  
Old June 13th, 2016, 08:17 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2016
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Smile checkou!

this is easiest

Private Sub Command1_Click()
If InputBox("") Mod 2 > 0 Then
MsgBox "Odd Number"
MsgBox "Even Number"
End If
End Sub
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Load VARIABLE Number of columns cosmokramer Oracle 1 November 2nd, 2008 05:51 PM
SELECT VARIABLE Number of columns drani Oracle 4 September 21st, 2008 01:12 AM
Problem with variable in test condition bartnowa XSLT 3 December 20th, 2007 07:31 AM
Number of table rows to a variable Paula222 Access VBA 2 February 7th, 2006 09:33 AM
variable number of fields in record manisha.anand Oracle 0 July 1st, 2004 05:00 PM

All times are GMT -4. The time now is 01:09 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.