Visual basic numer generators

Programming, for all ages and all languages.
Post Reply
nuno_silva_pt

Visual basic numer generators

Post 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
Eero Ränik

Re:Visual basic numer generators

Post 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
smartguy240

Re:Visual basic numer generators

Post 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 ;)
Eero Ränik

Re:Visual basic numer generators

Post by Eero Ränik »

But the result is as random as code from my message... ;)
smartguy240

Re:Visual basic numer generators

Post by smartguy240 »

you for got randomize with is a vb constant which actually brings the Rnd to be random
Eero Ränik

Re:Visual basic numer generators

Post by Eero Ränik »

I know... I should've defined the integer too you know.
jamescox3k

Re:Visual basic numer generators

Post by jamescox3k »

Sorry Patrick, this is just a technicality, but Randomize is not a VB constant it's a method
smartguy240

Re:Visual basic numer generators

Post by smartguy240 »

Ok.
jamescox3k

Re:Visual basic numer generators

Post by jamescox3k »

You should always care about what you code. I was just trying to help.
smartguy240

Re:Visual basic numer generators

Post by smartguy240 »

Its ok...i wasnt trying to be mean ;)
Post Reply