Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works

# Visual Logic Odd and Negative Numbers

### #1 FlipLipshizts Posted 16 November 2007 - 11:00 AM

FlipLipshizts

New Member

• Member
• 3 posts
Hello!

Wow. I am new to Visual logic so I will try to provide the most usefull info that I think is inportant. Hopefully someone can help with what I give:

- I am trying to create a program that can tell the difference between odd and even numbers.

- I already have the program created where it knows what is an odd or even (using the method of an IF condition with 0 < NUM, NUM being the number the user enters Mod 2-- example 5 MOD 2)

- I have the program looping untill the user gets it correct (using a while loop)

Everything is working good. My only problem? I want to include negative numbers!!!

Technically, this is more of a math question, but how do I incoperate negative intergers into this program? I am so stumped it is not even funny!

Thanks to anyone who can help!!
• 0

### #2 Ax238 Posted 16 November 2007 - 12:46 PM

Ax238

Tech Staff

• Technician
• 1,323 posts
Hi there and welcome to G2G!

Sounds like you are doing good so far. Sometimes when we programmers get stumped, we need to take a step back and look at things in a different way. Do you remember math problems in school where you'd have to take a number and find its absolute value? Same principle here and VB has a function you can use as well:
`NUM = Abs(UserNum Mod 2)`

The output of the above would leave NUM with a value of 1 if UserNum is -5.

Regards,

Ax

Edited by Ax238, 16 November 2007 - 12:47 PM.

• 0

### #3 FlipLipshizts Posted 16 November 2007 - 03:05 PM

FlipLipshizts

New Member

• Topic Starter
• Member
• 3 posts
WOW! Thanks so much! As soon as I saw about using absolute value a huge lightbulb went off!! My program worked! Yay!

Thanks!
• 0

### #4 Ax238 Posted 18 November 2007 - 12:15 AM

Ax238

Tech Staff

• Technician
• 1,323 posts
The lightbulb phenomenon is universal I think. You're much welcome, come back anytime!
• 0

### #5 hubz Posted 12 May 2012 - 10:07 AM

hubz

New Member

• Member
• 1 posts
hi!!! what is best ay to create a mod operation in a loop in visual logic
• 0

### Similar Topics

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users