?
Solved

How to call a function in vb

Posted on 2006-03-21
8
Medium Priority
?
186 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.
0
Comment
Question by:swansonplace
8 Comments
 
LVL 11

Expert Comment

by:leclairm
ID: 16248867
Can we see the subroutine??
0
 
LVL 11

Expert Comment

by:leclairm
ID: 16248887
or try:

importPOItems "C:\Program Files\filename",2
0
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
ID: 16248905
Hi swansonplace,
I think that you define it in form. You must define it in Module to run it from Debug windows

-FA
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 11

Expert Comment

by:leclairm
ID: 16248950
Without the brackets should work.
0
 
LVL 2

Expert Comment

by:KnobiKnobi
ID: 16249067
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))
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 16249072
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.


0
 
LVL 11

Accepted Solution

by:
leclairm earned 500 total points
ID: 16249127
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))>
0
 

Author Comment

by:swansonplace
ID: 16251308
THANKS
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month15 days, 12 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question