How to call a function in vb

Posted on 2006-03-21
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

Compile Error:
Expected: =

When I take out the 2 from the call and the subroutine, it works.

Thank you in advance.
Question by:swansonplace
    LVL 11

    Expert Comment

    Can we see the subroutine??
    LVL 11

    Expert Comment

    or try:

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

    Expert Comment

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

    LVL 11

    Expert Comment

    Without the brackets should work.
    LVL 2

    Expert Comment

    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))
    LVL 65

    Expert Comment

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

    LVL 11

    Accepted Solution

    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))>

    Author Comment


    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    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…

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now