Sorry, I am a beginner at Visual Basic, and have had to create this project as part of a school task. It keeps coming up with "argument not optional" on the calls tp checkcards and determinewinnings. I don't knkow what this means really, and I don't know how to fix it. Can you help??
Here is the code:
Option Explicit
Private Sub cmdDraw_Click()
'subroutine to "draw" the cards
Call GenerateCards 'calling the GenerateCards subroutine
Call CheckCards 'calling the CheckCards subroutine
Call DetermineWinnings 'calling the DetermineWinnings subroutine
End Sub
Private Sub cmdStart_Click()
'subroutine to activate the program when start is clicked
cmdDraw.Enabled = True 'enabling the "Draw" command button
Dim intwinnings As Integer 'declaring the intwinnings variable as an integer
intwinnings = 0 'setting intwinnings to 0
lblwinnings.Caption = intwinnings 'making the lblwinnings caption 0
Randomize 'Telling the program to generate random numbers
End Sub
Sub GenerateCards()
'subroutine to generate the random numbers for the variables
Dim intcard1, intcard2, intcard3, intcard4 As Integer 'Declaring the variables as integers
intcard1 = Int(Rnd * 4) + 1 'making the intcard1 variable equal to a random number between 1 & 2
intcard2 = Int(Rnd * 4) + 1 'making the intcard2 variable equal to a random number between 1 & 2
intcard3 = Int(Rnd * 4) + 1 'making the intcard3 variable equal to a random number between 1 & 2
intcard4 = Int(Rnd * 4) + 1 'making the intcard4 variable equal to a random number between 1 & 2
End Sub
Sub CheckCards(intcard1, intcard2, intcard3, intcard4 As Integer)
'subroutine to display image according to the values of the random numbers generated in the GenerateCards subroutine
If intcard1 = 1 Then 'Checking if the intcard1 variable is a 1 and if it is, generating a diamond card
imgcard1.Picture = imgdiamond.Picture
Else
If intcard1 = 2 Then 'Checking if the intcard1 variable is a 2 and if it is, generating a hearts card
imgcard1.Picture = imgheart.Picture
Else
If intcard1 = 3 Then
imgcard1.Picture = imgclub.Picture 'Checking if the intcard1 variable is a 3 and if it is, generating a clubs card
Else
If intcard1 = 4 Then
imgcard1.Picture = imgspade.Picture 'Checking if the intcard1 variable is a 4 and if it is, generating a spades card
End If
End If
End If
End If
If intcard2 = 1 Then 'Checking if the intcard2 variable is a 1 and if it is, generating a diamonds card
imgcard2.Picture = imgdiamond.Picture
Else
If intcard2 = 2 Then 'Checking if the intcard2 variable is a 2 and if it is, generating a hearts card
imgcard2.Picture = imgheart.Picture
Else
If intcard2 = 3 Then 'Checking if the intcard2 variable is a 3 and if it is, generating a clubs card
imgcard2.Picture = imgclub.Picture
Else
If intcard2 = 4 Then 'Checking if the intcard2 variable is a 4 and if it is, generating a spades card
imgcard2.Picture = imgspade.Picture
End If
End If
End If
End If
If intcard3 = 1 Then 'Checking if the intcard3 variable is a 1 and if it is, generating a diamonds card
imgcard3.Picture = imgdiamond.Picture
Else
If intcard3 = 2 Then 'Checking if the intcard3 variable is a 2 and if it is, generating a hearts card
imgcard3.Picture = imgheart.Picture
Else
If intcard3 = 3 Then 'Checking if the intcard3 variable is a 3 and if it is, generating a clubs card
imgcard3.Picture = imgclub.Picture
Else
If intcard3 = 4 Then 'Checking if the intcard3 variable is a 4 and if it is, generating a spades card
imgcard3.Picture = imgspade.Picture
End If
End If
End If
End If
If intcard4 = 1 Then 'Checking if the intcard4 variable is a 1 and if it is, generating a diamonds card
imgcard4.Picture = imgdiamond.Picture
Else
If intcard4 = 2 Then 'Checking if the intcard4 variable is a 2 and if it is, generating a hearts card
imgcard4.Picture = imgheart.Picture
Else
If intcard4 = 3 Then 'Checking if the intcard4 variable is a 3 and if it is, generating a clubs card
imgcard4.Picture = imgclub.Picture
Else
If intcard4 = 4 Then 'Checking if the intcard4 variable is a 4 and if it is, generating a spades card
imgcard4.Picture = imgspade.Picture
End If
End If
End If
End If
End Sub
Sub DetermineWinnings(intcard1, intcard2, intcard3, intcard4, intwinnings As Integer)
'subroutine to calculate, and keep tally of the user's winnings
If intcard1 = intcard2 = intcard3 = intcard4 Then 'Checking the cards for four of the same
intwinnings = intwinnings + 5 'stating that if a set of four is found, the winner receives $5
lblwinnings.Caption = intwinnings 'Updating the onscreen total
Else
If intcard1 = intcard2 = intcard3 Or intcard2 = intcard3 = intcard4 Or intcard1 = intcard2 = intcard4 Or intcard1 = intcard3 = intcard4 Then 'checking the cards for triplets
intwinnings = intwinnings + 3 'stating that if a triplet is found, the winner receives $3
lblwinnings.Caption = intwinnings 'updating the onscreen total
Else
If intcard1 = intcard2 Then 'checking the cards for pairs
intwinnings = intwinnings + 1 'stating the if a double is found, the winner receives $1 for each pair
lblwinnings.Caption = intwinnings 'updating the onscreen total
End If
If intcard2 = intcard3 Then 'checking the cards for pairs
intwinnings = intwinnings + 1 'stating the if a double is found, the winner receives $1 for each pair
lblwinnings.Caption = intwinnings 'updating the onscreen total
End If
If intcard3 = intcard4 Then 'checking the cards for pairs
intwinnings = intwinnings + 1 'stating the if a double is found, the winner receives $1 for each pair
lblwinnings.Caption = intwinnings 'updating the onscreen total
End If
If intcard1 = intcard3 Then 'checking the cards for pairs
intwinnings = intwinnings + 1 'stating the if a double is found, the winner receives $1 for each pair
lblwinnings.Caption = intwinnings 'updating the onscreen total
End If
If intcard1 = intcard4 Then 'checking the cards for pairs
intwinnings = intwinnings + 1 'stating the if a double is found, the winner receives $1 for each pair
lblwinnings.Caption = intwinnings 'updating the onscreen total
End If
If intcard2 = intcard4 Then 'checking the cards for pairs
intwinnings = intwinnings + 1 'stating the if a double is found, the winner receives $1 for each pair
lblwinnings.Caption = intwinnings 'updating the onscreen total
End If
End If
End If
End Sub