Pass Combobox value to Function

Timoo

Registered User.
Local time
Today, 01:10
Joined
May 9, 2012
Messages
30
Hi,

This should be pretty straightforward, but I do not seem to succeed.
How do I pass the value of a combobox to a function?

This is my current code:
Code:
Function UpdateDealer(iDealer As Integer, oDealer As Integer)
'stuff
End Function

And this is the code behind the button:
Code:
Private Sub Transitions_Click()
    Me.Recalc
    UpdateDealer(Me.NewDlr.Value, Me.OldDlr.Value)
End Sub

And it gives me an error. What do I do wrong?
error1.gif


Thanks in advance,
Timo
 
Last edited:
Hello Timo,

Since UpdateDelaer is declared as a Function, it will expect a return Value..

I am not sure what goes into the 'stuff here, I am not sure if you are returning a value or not.. If you have nowhere in the function
Code:
UpdateDealer = something
then you can use..
Code:
Private Sub Transitions_Click()
    Me.Recalc
    [COLOR=Red][B]Call[/B][/COLOR] UpdateDealer(Me.NewDlr.Value, Me.OldDlr.Value)
End Sub
If you are returning a value, then you might as well assign that return value to a variable..
Code:
Private Sub Transitions_Click()
    Dim tmpVar As Variant
    Me.Recalc
    tmpVar = UpdateDealer(Me.NewDlr.Value, Me.OldDlr.Value)
End Sub
Or even change the Function to a Sub, that will avoid the whole confusion..
Code:
Sub UpdateDealer(iDealer As Integer, oDealer As Integer)
    'stuff
End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom