Hey guys i'm new to visual basic and im trying to figure out where im going wrong. if you have any tip or a point in the right direction. i would be gratful thank you
Public Class frmMain
Public counter As Integer = 0
Public card1 As Integer
Public card2 As Integer
Private Sub btnHitme_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHitme.Click
counter = counter + 1
Dim card3 As Integer
Dim card4 As Integer
Dim card5 As Integer
Dim computercard1 As Integer
Dim computercard2 As Integer
Dim computercard3 As Integer
computercard1 = (10 * Rnd()) + 1
computercard2 = (10 * Rnd()) + 1
computercard3 = (10 * Rnd()) + 1
lblComputercard1.Text = computercard1
lblComputercard2.Text = computercard2
lblComputercard3.Text = computercard3
lblComputercard1.Visible = False
lblComputercard2.Visible = False
lblComputercard3.Visible = False
card1 = lblPlayercard1.Text
card2 = lblPlayercard2.Text
If counter = 1 Then
card3 = (10 * Rnd()) + 1
lblPlayercard3.Text = card3
End If
If counter = 2 Then
card4 = (10 * Rnd()) + 1
lblPlayercard4.Text = card4
End If
If counter = 3 Then
lblPlayercard5.Text = card5
End If
If counter >= 4 Then
MsgBox(" No more Cards!")
End If
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Randomize()
Dim card1 As Integer
Dim card2 As Integer
Dim card3 As Integer
card1 = (10 * Rnd()) + 1
card2 = (10 * Rnd()) + 1
lblPlayercard1.Text = card1
lblPlayercard2.Text = card2
lblPlayercard3.Text = card3
End Sub
Private Sub btnPlayAgain_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlayAgain.Click
Dim computercard1 As Integer
Dim computercard2 As Integer
Dim computercard3 As Integer
btnCheckscore.Enabled = True
btnHitme.Enabled = True
lblComputercard1.Text = ""
lblComputercard2.Text = ""
lblComputercard3.Text = ""
lblPlayercard1.Text = ""
lblPlayercard2.Text = ""
lblPlayercard3.Text = ""
lblPlayercard4.Text = ""
lblPlayercard5.Text = ""
lblPlayersum.Text = ""
counter = 0
lblComputercard1.Visible = False
lblComputercard2.Visible = False
lblComputercard3.Visible = False
End Sub
Private Sub btnCheckscore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheckscore.Click
btnHitme.Enabled = False
btnCheckscore.Enabled = False
If counter = 0 Then
lblPlayersum.Text = Val(lblPlayercard1.Text) + Val(lblPlayercard2.Text)
End If
If counter = 1 Then
lblPlayersum.Text = Val(lblPlayercard1.Text) + Val(lblPlayercard2.Text) + Val(lblPlayercard3.Text)
End If
If counter = 2 Then
lblPlayersum.Text = Val(lblPlayercard1.Text) + Val(lblPlayercard2.Text) + Val(lblPlayercard3.Text) + Val(lblPlayercard4.Text)
End If
If counter = 3 Then
lblPlayersum.Text = Val(lblPlayercard1.Text) + Val(lblPlayercard2.Text) + Val(lblPlayercard3.Text) + Val(lblPlayercard4.Text) + Val(lblPlayercard5.Text)
End If
If counter = 4 Then
lblPlayersum.Text = Val(lblPlayercard1.Text) + Val(lblPlayercard2.Text) + Val(lblPlayercard3.Text) + Val(lblPlayercard4.Text) + Val(lblPlayercard5.Text)
End If
lblComputersum.Text = Val(lblComputercard1.Text) + Val(lblComputercard2.Text) + Val(lblComputercard3.Text)
lblComputercard1.Visible = True
lblComputercard2.Visible = True
lblComputercard3.Visible = True
If lblPlayersum.Text = 21 And lblComputersum.Text < 21 Then
MsgBox("Your a Winnner!!")
End If
If lblPlayersum.Text = 21 And lblComputersum.Text > 21 Then
MsgBox("You a Winnner!")
End If
If lblPlayersum.Text = 21 And lblComputersum.Text = 21 Then
MsgBox("It's a Draw")
End If
If lblPlayersum.Text < 21 And lblComputersum.Text > 21 Then
MsgBox("Your a Winner")
End If
If lblPlayersum.Text < 21 And lblComputersum.Text < 21 Then
If lblPlayersum.Text = lblComputersum.Text Then
MsgBox("Its a Draw")
Else
If lblPlayersum.Text < lblComputersum.Text Then
MsgBox("The Computer is the Winner")
End If
End If
End If
End Sub
End Class