Solved

VBA compile error, Expected: =

Posted on 1998-06-22
4
585 Views
Last Modified: 2008-03-17
Private Declare Sub MySub Lib "MyDLL.DLL" (ByVal i As Integer, ByRef Text$)
...
MySub(i,Text$)
...

VBA compiler produces:

Compile error:
Expected: =

on the MySub line.


What is wrong?

Thanx

0
Comment
Question by:BobSamonik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Expert Comment

by:chapie
ID: 1463994
Private Declare Sub MySub Lib "MyDLL.DLL" (ByVal i As Integer, ByRef Text$)
    ...
    MySub(i,Text$)

My Question#1:  what does the $ at the end of your declaration do...I've not seen these used for variables like that, unless you have a custom data type declared, I'm not sure exactly but that could be a problem

My Question#2:  in MySub(i, Text$) you are trying to pass 2 arguements to the MySub procedure, why are you passing the arguement (or variable) names, you need to send some value such as MySub(5346, "Some Text")
0
 

Author Comment

by:BobSamonik
ID: 1463995
OK. I have a for next loop inside which I call MySub but each time with different arguments, that is why I use variable name in the call to MySub.

$ means that Text is string variable.

For the declaration that has only one argument MySub2(ByRef Text$) everything works fine MySub(Text$).
0
 
LVL 6

Accepted Solution

by:
clifABB earned 100 total points
ID: 1463996
Being a subroutine, MySub doesn't require parantheses unless you use the optional Call keyword.
Change the line to read either:
  MySub i,Text$
or
  Call MySub(i,Text$)

0
 
LVL 3

Expert Comment

by:chapie
ID: 1463997
arrgh...that should be right, I should have caught that when it said Required:=  I see that that too, when I use parenthasis when they aren't required
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

696 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