Link to home
Start Free TrialLog in
Avatar of swansonplace
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.
Avatar of leclairm
leclairm

Can we see the subroutine??
or try:

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
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, 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.


ASKER CERTIFIED SOLUTION
Avatar of leclairm
leclairm

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of swansonplace

ASKER

THANKS