?
Solved

VBA compile error, Expected: =

Posted on 1998-06-22
4
Medium Priority
?
602 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 400 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

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.

Question has a verified solution.

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

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…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

809 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