Reputation: 299
I have a class called cls_Utilitario with the method below:
Public Function LimparCampos(arg_form As Object)
Dim campo As Control
For Each campo In arg_form.Controls
With campo
Select Case .ControlType
Case acComboBox, acTextBox
.Value = Null
End Select
End With
Next campo
Set campo = Nothing
Set arg_form = Nothing
End Function
And I have the following code into the form:
Private Sub btnNovo_Click()
Dim obj_Utilitario As cls_Utilitario
Set obj_Utilitario = New cls_Utilitario
obj_Utilitario.LimparCampos (Me.Form)
End Sub
Why doen't it work if I changed the argument to "Object" type? I also tryed the "Variant" and "Form" types but, unsuccessfully.
Thanks in advance.
Upvotes: 1
Views: 4283
Reputation: 12745
Change
obj_Utilitario.LimparCampos (Me.Form)
to
Call obj_Utilitario.LimparCampos (Me.Form)
Or
obj_Utilitario.LimparCampos Me.Form
In VBA, you must not use the parentheses if you don't store the return value of the function in a variable or use the keyword Call
as shown.
Upvotes: 5