PSX5Central

Non Gaming Discussions => Off-Topic => Topic started by: PS2_-'_'-_PS2 on September 26, 2002, 02:14:39 PM

Title: Visual Basic problem......
Post by: PS2_-'_'-_PS2 on September 26, 2002, 02:14:39 PM
Just a question for you Visual basic people, any ideas why this code does not work:-

Private Sub cmdstart_Click()
Dim randomnum As Integer
Randomize
randomnum = Int(50 * Rnd + 1)
picnumber.Cls
picnumber.Print randomnum
If randomnum = 1 - 10 Then
    img1.Visible = True
End If
If randomnum = 11 - 20 Then
    img2.Visible = True
End If
If randomnum = 21 - 30 Then
    img3.Visible = True
End If
If randomnum = 31 - 40 Then
    img4.Visible = True
End If
If randomnum = 41 = 50 Then
    img5.Visible = True
End If
End Sub
Title: Re: Visual Basic problem......
Post by: SwifDi on September 26, 2002, 02:54:59 PM
Quote
Originally posted by PS2_-\'_\'-_PS2

If randomnum = 41 = 50 Then
    img5.Visible = True
End If
End Sub


Perhaps that extra "=" sign could be a problem, or a typo on your part. Why don\'t you use ElseIf statements?

Do you want to get numbers through 41 and 50, or are you subtracting 41 and 50? If you just want the numbers do

If randomnum >= 41 And randomnum <=50 Then

I\'m not sure what your trying to do though.
Title: Visual Basic problem......
Post by: PS2_-'_'-_PS2 on September 26, 2002, 03:02:46 PM
Thats the command i was thinking of but couldn\'t remember Elseif!!! thanks man!=]