I am making a Black jack game and i am trying to make it so that when my label which shows my current randomized valued which is "2,11" if this label = 10 then i would like it to randomize so that my picture box displays one of 3 randomized pictures for Jack Queen and King
Here is my Code:
Public Class Form1
Public YourCards As Integer = 0
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim TheRandomClass As New Random
Dim i As Integer = 0
i = TheRandomClass.Next(2, 11)
Label3.Text = i.ToString
YourCards += i
Label2.Text = "Your Cards: " + YourCards.ToString
If YourCards > 21 Then
MessageBox.Show("You Lose!")
YourCards = 0
Label3.Text = ""
Label2.Text = "Your Cards: 0"
End If
If YourCards = 21 Then
MessageBox.Show("You Won")
YourCards = 0
Label3.Text = ""
Label2.Text = "Your Cards: 0"
End If
If YourCards > 18 Then
While YourCards < 21
YourCards = 0
Label3.Text = ""
Label2.Text = "Your Cards: 0"
If YourCards > 18 Then
While YourCards < 21
MessageBox.Show("You Tied")
End While
End If
End While
End If
If Label3.Text = "2" Then
PictureBox1.ImageLocation = "C:\Documents and Settings\Souter\My Documents\My Pictures\2.GIF"
End If
If Label3.Text = "3" Then
PictureBox1.ImageLocation = "C:\Documents and Settings\Souter\My Documents\My Pictures\3.GIF"
End If
If Label3.Text = "4" Then
PictureBox1.ImageLocation = "C:\Documents and Settings\Souter\My Documents\My Pictures\4.GIF"
End If
If Label3.Text = "5" Then
PictureBox1.ImageLocation = "C:\Documents and Settings\Souter\My Documents\My Pictures\5.GIF"
End If
If Label3.Text = "6" Then
PictureBox1.ImageLocation = "C:\Documents and Settings\Souter\My Documents\My Pictures\6.GIF"
End If
If Label3.Text = "7" Then
PictureBox1.ImageLocation = "C:\Documents and Settings\Souter\My Documents\My Pictures\7.GIF"
End If
If Label3.Text = "8" Then
PictureBox1.ImageLocation = "C:\Documents and Settings\Souter\My Documents\My Pictures\8.GIF"
End If
If Label3.Text = "9" Then
PictureBox1.ImageLocation = "C:\Documents and Settings\Souter\My Documents\My Pictures\9.GIF"
End If
If Label3.Text = "10" Then
Select Case TheRandomClass
Case PictureBox1.ImageLocation = "C:\Documents and Settings\Souter\My Documents\My Pictures\Jack.GIF"
End Select
This is where i need help this line of code ^ the error "Error 1 Operator '=' is not defined for types 'System.Random' and 'Boolean' " comes up
End If
If Label3.Text = "11" Then
PictureBox1.ImageLocation = "C:\Documents and Settings\Souter\My Documents\My Pictures\Ace.GIF"
End If
End Sub
Private Sub ResetGameToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResetGameToolStripMenuItem.Click
YourCards = 0
Label3.Text = ""
Label2.Text = "Your Cards: o"
End Sub
End Class
If anyone can help me it would be much appreciated