Solved

VBA compile error, Expected: =

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb6 programatically bring window to front 8 63
MS Access Search and Replace Using VBA 6 57
Add a task in Outlook from access 11 35
Visual Studio 2005 text editor 10 35
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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

911 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

19 Experts available now in Live!

Get 1:1 Help Now