Hi,
I have a problem with function and sub using this function. Everything work if I use value of argument (integer in this case) and gives and ByRef argument type mismatch if I try to use integer variable.
situation is as follows:
I have a public function in ThisWorkbook:
Public Function SprawdzNumer(g As String, num As Integer) As Integer
....
end function
This function works.
Than in user form I have sub that uses this function. This sub is than used by various controlls.
Sub SprawdzNumer()
If Not numer = 0 Then
If Dodanie_nowego.Combo_grupa.ListIndex > -1 Then
Dim i As Integer
i = ThisWorkbook.SprawdzNumer("I", 500)
If i = 1 Then
MsgBox ("Numer już występuje. Proszę podać inny lub wybrać opcję 'AUTO'")
Dodanie_nowego.Text_numer.Value = vbNullString
numer = 0
ElseIf i = -1 Then
MsgBox ("Nieprawidłowy symbol grupy")
End If
End If
End If
' ElseIf Len(Dodanie_nowego.Text_numer.Text) < 1 Then
End Sub
as you can see in the line :
i = ThisWorkbook.SprawdzNumer("I", 500)
I had put values "I" and 500 (now they are static to avoid problems).
Than in one of control buttons I call SprawdzNumer sub. and that is where I got error.
Private Sub CommandButton1_Click()
MsgBox ("Numer: " & numer)
MsgBox (ThisWorkbook.SprawdzNumer("I", numer))
End Sub
numer is integer variable declared in this userform. Its value is 500 (for tests).
If I run the same code only not using numer variable but value of 500 I got no errors.
What is wrong?
Cris
Bookmarks