Hey, I'm a student with rudimentry knoledge of VB6 and I've a college project where I have to develop a blackjack game. Unfortuanately I've a problem with the method I call the cards I was wondering if any of you would be able to shed some light on the problem.

Option Explicit

Private Sub Command1_Click()

Dim card(5) As Integer
Dim x As Integer
Dim y As Integer
Dim d As Integer
Dim discard(5) As Integer

x = 0
y = 0
d = x - 1

Randomize

card(x) = Int((52 * Rnd) + 1)
Debug.Assert (Val(card(x)))

Do While (y < 5)
Call deal
If discard(x) = card(x) Then
Call deal
End If
y = y + 1
Loop

End Sub

Private Function deal(ByVal card As Integer, x As Integer, y As Integer)

For x = 0 To 4 Step 1
Select Case card(x)
Case Is = 1
Picture1(x).Picture = LoadPicture("F:\Cards\HA.jpg")

Case Is = 2
Picture1(x).Picture = LoadPicture("F:\Cards\H2.jpg")

'same every other card untill 52

End Select
Next y
End Function

Any help will be more than welcome but please keep it somewhat simple so I can understand lol.

Hey, I'm a student with rudimentry knoledge of VB6 and I've a college project where I have to develop a blackjack game. Unfortuanately I've a problem with the method I call the cards I was wondering if any of you would be able to shed some light on the problem.

You didn't explain the problem. You need to give us details. Don't make us try to understand the code you wrote that you can easily describe, without an explanation of what the trouble is.

Details, please.

see I don't quite know what's wrong. whenever i hit the comand button, I get an error saying "argument not optional" and I don;t know what that means, I'm thinking that there must be multiple problems that I cannot see.

see I don't quite know what's wrong. whenever i hit the comand button, I get an error saying "argument not optional" and I don;t know what that means, I'm thinking that there must be multiple problems that I cannot see.

Neither do we. If you are really using Visual Basic, in my experience the program stops on the statement that is causing the problem. That might be one of the details you need to give us -- the line in error. And a couple lines above and below in case they might shed some light on the issue too.

And what does that proceedure look like? Also, the randomize statement should only be called once in the lifetime of a program, which means you should move it to your startup object, either sub main or form load.

Good Luck

Did you define the deal() function to take parameters?
If so, did you pass parameters on the call deal line?

Thanks WaltP for that it helped a lot. VB5, what do you mean it should only be used once? I need it to constantly generate the random number for the card (each card is assigned a number and the generator chooses that card's number and then the rest displays it. Although now when I run the program on the function start line (which I've now got as

Private Function deal(ByVal card(5), x)As Integer
'cards
end function

it now comes up with "compile error: expected: )" any ideas please?

See... http://support.microsoft.com/kb/231847 and http://support.microsoft.com/kb/28150/EN-US/ although this is a bit out of date... and this is probably a bit too indepth on math functions for you but here it is anyways... http://support.microsoft.com/kb/196652

and it should be ByRef card() if you want to pass the contents of an array as you cannot pass an array byval. Or it should be ByVal card if you only want to pass one element of an array (Call MySub(MyArray(1)))...


Good Luck

Thanks all that have helped, my program is finished. Really I couldnn't have done without you. :D

This question has already been answered. Start a new discussion instead.