|
-
Oct 31st, 2001, 05:05 PM
#1
Thread Starter
Stuck in the 80s
Random Numbers
How can I get a random number that's sometimes negative, and sometimes positive?
-
Oct 31st, 2001, 05:09 PM
#2
PowerPoster
VB Code:
Dim intRnd As Long
Randomize
intRnd = Int((999 - -999 + 1) * Rnd + -999)
MsgBox intRnd
-
Oct 31st, 2001, 05:25 PM
#3
I'm not sure chrisjk's code is going to work as is.
Anyway - here's another version
Code:
Function num() as integer
Dim j as single
dim i as integer
j = rnd
if j> .5 then
i = 1
else
i = -1
end if
num = int (rnd*999 +1) * i
End Function
-
Oct 31st, 2001, 05:28 PM
#4
PowerPoster
certainly does, tried and tested
-
Nov 1st, 2001, 02:31 AM
#5
Conquistador
Yes it works, perhaps you should have tested it mcnamara
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|