lashman
04-19-2003, 06:12 AM
Hello
I was adding this function to a simple application. But I get compile error: Argument not optional when I try to run this function. I wrote this code fully working yesterday. But today I can't.
Public Function sok3(tal1 As Integer, tal2 As Integer, tal3 As Integer) As Boolean
If tal1 = 1 Then
sok3 = True
Exit Function
ElseIf tal2 = 2 Then
sok3 = True
Exit Function
ElseIf tal3 = 3 Then
sok 3 = True
Exit Function
Else
sok3 = False
End If
End Function
My code to run this function:
Private Sub cmd1_Click()
Dim t1 As Integer, t2 As Integer, t3 As Integer
Dim resultat As Integer, summa As Integer
t1 = txt1.Text
t2 = txt2.Text
t3 = txt3.Text
resultat = antpos3(t1, t2, t3)
summa = sum3(t1, t2, t3)
MsgBox "Antal positiva " & resultat, , "TEST"
MsgBox "Summa " & summa, , "TEST"
If sok3(t1, t2, t3) = True Then <------------------------
chk1.Value = Checked
Else
chk1.Value = Unchecked
End If
cmd1.Enabled = False
End Sub
What am I doing wrong here? How do I call this function and make it check if number 1 is in txt1.text textbox etc? It's also supposed to check chk1 checkbox when true.
I was adding this function to a simple application. But I get compile error: Argument not optional when I try to run this function. I wrote this code fully working yesterday. But today I can't.
Public Function sok3(tal1 As Integer, tal2 As Integer, tal3 As Integer) As Boolean
If tal1 = 1 Then
sok3 = True
Exit Function
ElseIf tal2 = 2 Then
sok3 = True
Exit Function
ElseIf tal3 = 3 Then
sok 3 = True
Exit Function
Else
sok3 = False
End If
End Function
My code to run this function:
Private Sub cmd1_Click()
Dim t1 As Integer, t2 As Integer, t3 As Integer
Dim resultat As Integer, summa As Integer
t1 = txt1.Text
t2 = txt2.Text
t3 = txt3.Text
resultat = antpos3(t1, t2, t3)
summa = sum3(t1, t2, t3)
MsgBox "Antal positiva " & resultat, , "TEST"
MsgBox "Summa " & summa, , "TEST"
If sok3(t1, t2, t3) = True Then <------------------------
chk1.Value = Checked
Else
chk1.Value = Unchecked
End If
cmd1.Enabled = False
End Sub
What am I doing wrong here? How do I call this function and make it check if number 1 is in txt1.text textbox etc? It's also supposed to check chk1 checkbox when true.