# Visual Logic Odd and Negative Numbers - Geeks to Go Forums

## Visual Logic Odd and Negative Numbers Need help please!

### #1FlipLipshizts

• Group: Member
• Posts: 3
• Joined: 16-November 07

Posted 16 November 2007 - 11:00 AM

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!!

### #2Ax238

• Group: Technician
• Posts: 1,323
• Joined: 09-November 07

Posted 16 November 2007 - 12:46 PM

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

### #3FlipLipshizts

• Group: Member
• Posts: 3
• Joined: 16-November 07

Posted 16 November 2007 - 03:05 PM

WOW! Thanks so much! As soon as I saw about using absolute value a huge lightbulb went off!! My program worked! Yay!

Thanks!

### #4Ax238

• Group: Technician
• Posts: 1,323
• Joined: 09-November 07

Posted 18 November 2007 - 12:15 AM

The lightbulb phenomenon is universal I think. You're much welcome, come back anytime!

### #5hubz

• Group: Member
• Posts: 1
• Joined: 10-May 12

Posted 12 May 2012 - 10:07 AM

hi!!! what is best ay to create a mod operation in a loop in visual logic