r/visualbasic • • Mar 07 '21

I need help programming a card game in VB

Post image
0 Upvotes

8 comments sorted by

11

u/JamesWjRose Mar 07 '21

friendly advice: Ask specific questions. People are not here to do the work for you, and this post is completely worthless.

Best of luck to you

1

u/Affectionate_Algae66 Mar 08 '21

thats what i used the comment for

2

u/chacham2 Mar 08 '21

If you don't put the code it the main post, i am not sure most people will see it. Please create another post, but this time of your actual code on it, fotmatted by preceding each line with four spaces.

1

u/Affectionate_Algae66 Mar 07 '21

I started creating the deck with arrays, but I have trouble connecting the arrays to the visual output, I dont know how to make every card appear only once

2

u/banshoo Mar 08 '21

So what code do you have?

1

u/Affectionate_Algae66 Mar 08 '21

Sub Deck()

Dim Deck(4, 8) As String

Deck(1, 1) = "Herz" And "7" Deck(1, 2) = "Herz" And "8" Deck(1, 3) = "Herz" And "9" Deck(1, 4) = "Herz" And "10" Deck(1, 5) = "Herz" And "Bube" Deck(1, 6) = "Herz" And "Dame" Deck(1, 7) = "Herz" And "König" Deck(1, 8) = "Herz" And "Ass" Deck(2, 1) = "Pik" And "7" Deck(2, 2) = "Pik" And "8" Deck(2, 3) = "Pik" And "9" Deck(2, 4) = "Pik" And "10" Deck(2, 5) = "Pik" And "Bube" Deck(2, 6) = "Pik" And "Dame" Deck(2, 7) = "Pik" And "König" Deck(2, 8) = "Pik" And "Ass" Deck(3, 1) = "Karo" And "7" Deck(3, 2) = "Karo" And "8" Deck(3, 3) = "Karo" And "9" Deck(3, 4) = "Karo" And "10" Deck(3, 5) = "Karo" And "Bube" Deck(3, 6) = "Karo" And "Dame" Deck(3, 7) = "Karo" And "König" Deck(3, 8) = "Karo" And "Ass" Deck(4, 1) = "Kreuz" And "7" Deck(4, 2) = "Kreuz" And "8" Deck(4, 3) = "Kreuz" And "9" Deck(4, 4) = "Kreuz" And "10" Deck(4, 5) = "Kreuz" And "Bube" Deck(4, 6) = "Kreuz" And "Dame" Deck(4, 7) = "Kreuz" And "König" Deck(4, 8) = "Kreuz" And "Ass" End Sub

sub randomarray()

Number1= int((32×rnd)+1)

end sub

Sub umwandeln() If Label3.Caption = 1 Then Label3.Caption = Deck(1, 1)

End Sub

I think the upper array part should not be wrong, I tried to generate a random number and connect each number to a card but its not really working

5

u/PostalElf VB.Net Intermediate Mar 08 '21

If your array is properly initialized, it should be trivial to display each card once because you'll only have one of each card in your deck. Post your code and we'll have a look.

2

u/tmntfever Mar 08 '21

Make sure you’re actually using an array and not like a stack, where if you Pop(), then you will lose a reference to that card if you don’t store it in another stack.