vb6 help needed please!!!

killzoneman0

In Runtime
Messages
342
i am making a text-adventure game in visual basic 6 and was wondering how i could randomize an event that occurs. an example would be a label that pops up randomly in the game and says "you encounter dust storm and lose 3 health"

does anyone know of any code that could do this?
 
Since it's a text adventure.... use code that simulates a dice being rolled...
Code:
Private Sub Form_Load()
  'Initialize the psuedo-random # generator.
  Randomize
End Sub
this is a regular 6 sided dice.
Code:
private sub button1_click()
DieValue = Rand(1, 6)

if DieValue = 1 then
msgbox "you encounter dust storm and lose 3 health" 
end if

end sub


change this line
Code:
DieValue = Rand(1, 6)
for more values

eg 24side dice
Code:
DieValue = Rand(1, 24)
 
Private Sub Form_Load()
'Initialize the psuedo-random # generator.
Randomize
End Sub


Private Sub Command1_Click()
DieValue = Randomize(1, 6)
If DieValue = 1 Then
MsgBox "you encounter dust storm and lose 3 health"
Else
MsgBox "it didnt work"
End If
End Sub





when i hit the command button it highlights randomize in the command_click and a messagebox says"compile error: wrong number of arguements or invalid property assignment"

when i go to the object browser, it says that "Sub Randomize([Number])" is the right way to put it. it also says that it initializes the random number generator.

what do i do now?
 
Er... How about you refer to root's earlier post and check out the part about the function Rand, not Randomize. One sets the psuedorandom seed for the initialization (Randomize) and gets used only once. The other (Rand) is used to get a random number returned within a specified range ( as in DieValue = Rand(1,6) ). Recheck your code and try, try again... :)
 
Back
Top Bottom