Reputation: 1
I am trying to create a 5 card draw poker program.
Dim Rndm As New Random
Dim PictureBox(5) As PictureBox
Dim HiddenCards As New List(Of String)
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim CardDeck() As String = {"AoH", "AoD", "AoC", "AoS", "ONEoH", "ONEoD", "ONEoC", _
"ONEoS", "TWOoH", "TWOoD", "TWOoC", "TWOoS", "THREEoH", "THREEoD", "THREEoC", _
"THREEoS", "FOURoH", "FOURoD", "FOURoC", "FOURoH", "FIVEoH", "FIVEoD", _
"FIVEoC", "FIVEoS", "SIXoH", "SIXoD", "SIXoC", "SIXoS", "SEVENoH", _
"SEVENoD", "SEVENoC", "SEVENoS", "EIGHToH", "EIGHToD", "EIGHToC", "EIGHToS", _
"NINEoH", "NINEoD", "NINEoC", "NINEoS", "TENoH", "TENoD", "TENoC", _
"TENoS", "JoH", "JoD", "JoC", "JoS", "QoH", "QoD", _
"QoC", "QoS", "KoH", "KoD", "KoC", "KoS"}
Dim ListofCards As List(Of String) = CardDeck.ToList
Dim Count As Integer = 0
Dim Selected As Integer = 0
For intCard As Integer = 0 To 5
Count = ListofCards.Count
Selected = Rndm.Next(0, Count)
PictureBox(intCard) = PictureBox1
With PictureBox(intCard).Image = My.Resources.CardDeck()
End With
Next
End Sub
I am specifically trying to figure out how to get the selected card from the CardDeck
string to load since I have a rnd function to randomly generate a card. I want to get this working before I move onto the next part. The error it gives me is this:
CardDeck
is a type in resources and cannot be used as an expression.
Can someone point to what exactly I am doing wrong and also tell me how I can load the randomly generated card?
Upvotes: 0
Views: 473
Reputation: 7082
You're trying to use the With...End With Statement and your syntax is wrong that's why you came up to that error.
EDIT:
For intCard As Integer = 0 To 5
Count = ListofCards.Count
Selected = Rndm.Next(0, Count)
PictureBox(intCard) = PictureBox1
With PictureBox(intCard)
.Image = My.Resources.CardDeck()
End With
Next
Upvotes: 1