Need help with arrays

Khyzinn

New member
Joined
Mar 8, 2010
Messages
4
Programming Experience
Beginner
Hey all,

I'm new here and to VB.NET and i don't know if i should post this on this part of the forum, so forgive me if i'm wrong.

We have to make a blackjack game for school. I'm not gonna ask if anyone can make it for me, but i'm just stuck with arrays. We have to use arrays, and we want to use them to shuffle our card deck. We have something like this, but i doubt it's correct.

Dim cards(12) As Integer
cards = New Integer() {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}

I don't know if it's correct, and in the small possiblity that it is, how can i integrate it in my code? I'm using the array in a class i made.

Thanks in advance.
 
A little help

Hi,

Yes that looks a good start
Dim cards(12) As Integer
cards = New Integer() {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}
Now you could initialise a random number using the system date:
Dim rand As New Random(CInt(Date.Now.Ticks And Integer.MaxValue))
And call the rand.next function with boundaries 1 to 13
MsgBox(rand.Next(1, 13))
This selects a number randomly inclusively between 1 and 13.

You might also make your array
cards = New Integer() {A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K}
and display a random card
msgbox (cards(rand.Next(1, 13)))

And for playing blackjack you might want an array that looks like this
BJscore = New Integer() {11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10}
though you would need alternative logic for scoring an ace as 1 or 11!

Just some thoughts, hope they help

Peter
 
Back
Top