austenr
02-08-2010, 04:54 PM
What would you have to write if no one clicked a button on a form to not allow them to exit the form? I've got this but it doesnt work:
Public Sub btnAirplane_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAirplane.Click
Dim AirplaneCnt As Integer
AirplaneCnt = AirplaneCnt + 1
pbAirplane.Visible = True
pbBall.Visible = False
pbDoll.Visible = False
End Sub
Public Sub btnBall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBall.Click
Dim BallCnt As Integer
BallCnt = BallCnt + 1
pbBall.Visible = True
pbAirplane.Visible = False
pbDoll.Visible = False
End Sub
Public Sub btnDoll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDoll.Click
Dim DollCnt As Integer
DollCnt = DollCnt + 1
pbDoll.Visible = True
pbAirplane.Visible = False
pbBall.Visible = False
End Sub
Public Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Dim BallCnt, AirplaneCnt, DollCnt As Integer
If BallCnt < 0 Or AirplaneCnt < 0 Or DollCnt < 0 Then
MsgBox("You cannot exit without selecting any gifts!!")
Else
Me.Close()
End If
End Sub
Public Sub btnAirplane_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAirplane.Click
Dim AirplaneCnt As Integer
AirplaneCnt = AirplaneCnt + 1
pbAirplane.Visible = True
pbBall.Visible = False
pbDoll.Visible = False
End Sub
Public Sub btnBall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBall.Click
Dim BallCnt As Integer
BallCnt = BallCnt + 1
pbBall.Visible = True
pbAirplane.Visible = False
pbDoll.Visible = False
End Sub
Public Sub btnDoll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDoll.Click
Dim DollCnt As Integer
DollCnt = DollCnt + 1
pbDoll.Visible = True
pbAirplane.Visible = False
pbBall.Visible = False
End Sub
Public Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Dim BallCnt, AirplaneCnt, DollCnt As Integer
If BallCnt < 0 Or AirplaneCnt < 0 Or DollCnt < 0 Then
MsgBox("You cannot exit without selecting any gifts!!")
Else
Me.Close()
End If
End Sub