We help IT Professionals succeed at work.

How to call a function in vb

swansonplace
swansonplace asked
on
Medium Priority
202 Views
Last Modified: 2010-04-07
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.
Comment
Watch Question

leclairm.Net Developer  ERP integration

Commented:
Can we see the subroutine??
leclairm.Net Developer  ERP integration

Commented:
or try:

importPOItems "C:\Program Files\filename",2
CERTIFIED EXPERT

Commented:
Hi swansonplace,
I think that you define it in form. You must define it in Module to run it from Debug windows

-FA
leclairm.Net Developer  ERP integration

Commented:
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))
Jim HornSQL Server Data Dude
CERTIFIED EXPERT
Most Valuable Expert 2013
Author of the Year 2015

Commented:
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.


.Net Developer  ERP integration
Commented:
Call importPOItems("C:\Program Files\filename",2)  works as well.

But like KnobiKnobi said:
<if the function is not in an form or a class (which needs an instance, which does not exist in design time))>

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
THANKS
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.