Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Testing a condition? 1

Status
Not open for further replies.

VBUser77

MIS
Jan 19, 2005
95
0
0
US
I am trying to compute a varaible through the following formula:

dim avg as integer
dim test as integer
test = 1

avg = (test = 1)* 4

Debug.Print avg

it gives me -4 instead of 4. My test condition (test = 1) should return me 1 and my average should be 4 instead of
-4.

Any ideas why it's doing this? Thanks a lot for your help.

Jay
 
(test = 1) returns a boolean value, ie 0 for false and -1 for true.
You wanted this ?
avg = IIf(test=1, 4, 0)
Or this ?
avg = Abs(test = 1) * 4

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top