Page 1 of 1

Visual basic numer generators

Posted: Thu Apr 03, 2003 10:37 am
by nuno_silva_pt
hi!
i want to know how can i make vb choose between 1 or 2 randomly for a soccer simulator game that uses the goals engine like this:
private sub form_load()
timer1.enabled
end sub
private sub timer1()
lblg1tmp.caption= "1" or "2"
lblg1.caption or lblg2.caption= lblg1tmp.caption
end sub

Re:Visual basic numer generators

Posted: Thu Apr 03, 2003 1:41 pm
by Eero Ränik
If I can understand your question correctly, then it should be like here:
random = int(rnd() * 2) + 1
select case random
case 1
lblg1.caption = lblg1tmp.caption
case 2
lblg2.caption = lblg1tmp.caption
end select

Re:Visual basic numer generators

Posted: Thu Apr 10, 2003 8:43 pm
by smartguy240
actually eero....that woulndt be exactly all that "random"

a better example would be this

Code: Select all

'General Declarations

Dim intRandom as Integer
---------------------------

'Sub Procedure

Randomize
intRandom = int((Highnumber - Lownumber + 1)* Rnd)+ Lownumber

intRandom is your Random integer

this is the most accurate randomizing format known to all man ;)

Re:Visual basic numer generators

Posted: Fri Apr 11, 2003 6:12 am
by Eero Ränik
But the result is as random as code from my message... ;)

Re:Visual basic numer generators

Posted: Fri Apr 11, 2003 10:14 am
by smartguy240
you for got randomize with is a vb constant which actually brings the Rnd to be random

Re:Visual basic numer generators

Posted: Fri Apr 11, 2003 3:29 pm
by Eero Ränik
I know... I should've defined the integer too you know.

Re:Visual basic numer generators

Posted: Thu Apr 17, 2003 11:52 am
by jamescox3k
Sorry Patrick, this is just a technicality, but Randomize is not a VB constant it's a method

Re:Visual basic numer generators

Posted: Tue Apr 22, 2003 4:54 pm
by smartguy240
Ok.

Re:Visual basic numer generators

Posted: Tue Apr 22, 2003 4:59 pm
by jamescox3k
You should always care about what you code. I was just trying to help.

Re:Visual basic numer generators

Posted: Tue Apr 22, 2003 6:37 pm
by smartguy240
Its ok...i wasnt trying to be mean ;)