PDA

View Full Version : VB.net random loop error


jmoney3457
11-23-2007, 02:45 AM
ok so i've made this random loop car race in VB.net but when i try to debug it..i get the following 2 errors in this SS you can see circled in black http://tinypic.com/fullsize.php?pic=7wr6d6h&s=1 & here my code:

Option Strict Off
Option Explicit On
Friend Class Form1
Inherits System.Windows.Forms.Form
End Class
Private Sub btngo_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles btngo.Click

Dim intRnd1, intRnd2 As Short

Randomize()

Do While VB6.PixelsToTwipsY(imgcar1.Top) > 0 And VB6.PixelsToTwipsY(imgcar2.Top) > 0 > And VB.6PixelstotwipsY(imgcar3.top)'do the loop while neither

intRnd1 = Int((45) * Rnd() + 10) 'rocket ship is at the top

intRnd2 = Int((50 - 10 + 1) * Rnd() + 10)

imgcar1.Top = VB6.TwipsToPixelsY(VB6.PixelsToTwipsY(imgcar1.Top) - intRnd1) 'subtract random number

imgcar2.Top = VB6.TwipsToPixelsY(VB6.PixelsToTwipsY(imgcar2.Top) - intRnd2) 'from the Top property

imgcar3.Top = VB6.TwipsToPixelsY(VB6.PixelsToTwipsY(imgcar3.Top) - intRnd2) 'from the Top property

Loop

If VB6.PixelsToTwipsY(imgcar1.Top) <= 0 And VB6.PixelsToTwipsY(imgcar2.Top) <= 0 And VB6.PixelsToTwipsY(imgcar3.Top) Then 'all 3 cars are at top

MsgBox("It's a tie!!")

Else

If VB6.PixelsToTwipsY(imgcar1.Top) <= 0 Then 'first car is at top

MsgBox("car 1 wins!!")

Else
If VB6.PixelsToTwipsY(imgcar2.Top) <= 0 Then 'second car is at top


MsgBox("car 2 wins!!")

If VB6.PixelsToTwipsY(imgcar3.Top) <= 0 Then 'third car is at top

MsgBox("car 3 wins!!")
End If

End If

imgcar.Top = VB6.TwipsToPixelsY(5200)

imgcar2.Top = VB6.TwipsToPixelsY(5200)

imgcar3.Top = VB6.TwipsToPixelsY(5200)
End Sub
Private Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnexit.Click

Me.Close()
End Sub anyone know which lines are causing those 2 errors?

Roelf
11-23-2007, 09:55 AM
shouldnt the Private subs be enclosed within the class definition?

so the End Class moved to the end of this code snippet?

jmoney3457
11-24-2007, 03:48 AM
tried that..but now its giving me more & different errors..is there simple way to c/p the errors into here?