0

I have below procedure in Module1:

public sub Evaluate(Salary as double)
    Dim Overtimesalary as Double
    Overtimesalary = salary * 1.5
End Sub

Now, I am calling this procedure for my form click button event to calculate overtime salary and taking input value from textbox value from form, Code for that,

When I am trying to execute below code, I am getting "Compile error: Expected function or variable":

Private sub cmd_Calculate()
    Dim Test as Double
    test = Evaluate(txt.salary.value)
    MsgBox Test
End Sub

1 Answer 1

1

Convert your subroutine into a Function, and return your value as the function's value.

public Function Evaluate(Salary as double)
    Evaluate = salary * 1.5
End Sub

This will run the procedure, perform the calculation, then return the value assigned within the function to the calling subroutine.

That said, I'm assuming that this is a simplified version of what you're actually doing - if all you're doing is literally multiplying a value by 1.5, you can just do that in the main subroutine!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.