Solved

VBA compile error, Expected: =

Posted on 1998-06-22
4
576 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
  • 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 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

14 Experts available now in Live!

Get 1:1 Help Now