Jump to content

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
Photo

Visual Logic Odd and Negative Numbers


  • Please log in to reply

#1
FlipLipshizts

FlipLipshizts

    New Member

  • Member
  • Pip
  • 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

Advertisements


#2
Ax238

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

FlipLipshizts

    New Member

  • Topic Starter
  • Member
  • Pip
  • 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

Ax238

    Tech Staff

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

#5
hubz

hubz

    New Member

  • Member
  • Pip
  • 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

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP