swansonplace
asked on
How to call a function in vb
How do I call a function in vb?
In the immediate window, I have entered:
importPOItems("C:\Program Files\filename",2)
the function is defined as follows:
Sub ImportPOItems(ByRef sFileName As String, intControlRef As Integer)
...
End Sub
Error:
Compile Error:
Expected: =
When I take out the 2 from the call and the subroutine, it works.
Thank you in advance.
In the immediate window, I have entered:
importPOItems("C:\Program Files\filename",2)
the function is defined as follows:
Sub ImportPOItems(ByRef sFileName As String, intControlRef As Integer)
...
End Sub
Error:
Compile Error:
Expected: =
When I take out the 2 from the call and the subroutine, it works.
Thank you in advance.
Can we see the subroutine??
or try:
importPOItems "C:\Program Files\filename",2
importPOItems "C:\Program Files\filename",2
Hi swansonplace,
I think that you define it in form. You must define it in Module to run it from Debug windows
-FA
I think that you define it in form. You must define it in Module to run it from Debug windows
-FA
Without the brackets should work.
Right. Using brakets here needs a leading "call ", so
call importPOItems("C:\Program Files\filename",2) should work too,
(if the function is not in an form or a class (which needs an instance, which does not exist in design time))
call importPOItems("C:\Program Files\filename",2) should work too,
(if the function is not in an form or a class (which needs an instance, which does not exist in design time))
Call importPOItems("C:\Program Files\filename",2) should work, but the way you did it should work as well.
Instead of Sub make it Public Sub, and make sure it's in a separate code module, and see what happens.
Instead of Sub make it Public Sub, and make sure it's in a separate code module, and see what happens.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
THANKS