Hello

Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: Visual Basic problem......  (Read 551 times)

Offline PS2_-'_'-_PS2
  • Sore Fingers
  • Hero Member
  • *****
  • Posts: 1729
  • Karma: +10/-0
    • http://
Visual Basic problem......
« 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
\"A key to the understanding of all religions is that a god\'s idea of amusement is Snakes and Ladders with greased rungs\"


http://www.purevolume.com/forgettheletterfour

Offline SwifDi
  • Legendary Member
  • ******
  • Posts: 9620
  • Karma: +10/-0
Re: Visual Basic problem......
« Reply #1 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.

Offline PS2_-'_'-_PS2
  • Sore Fingers
  • Hero Member
  • *****
  • Posts: 1729
  • Karma: +10/-0
    • http://
Visual Basic problem......
« Reply #2 on: September 26, 2002, 03:02:46 PM »
Thats the command i was thinking of but couldn\'t remember Elseif!!! thanks man!=]
\"A key to the understanding of all religions is that a god\'s idea of amusement is Snakes and Ladders with greased rungs\"


http://www.purevolume.com/forgettheletterfour

 

SMF spam blocked by CleanTalk