?
Solved

VBA compile error, Expected: =

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

Technology Partners: 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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 Month12 days, 3 hours left to enroll

752 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