Newbie problem: Compile error: expected =

D

Deryck

Hi,

I get this error whenever I try to call a sub. The sub is in a class module.
I have all the arguments in the correct order, one long and 5 strings but I
get the compile error as soon as I finish typing the line. The editor
clearly recogises the sub because it shows me the arguments as I type. Other
functions and subs in that lass module are called without problem.

I am completely stumped. Can anyone offer any clues please?

Thanks

Deryck
 
C

Chip Pearson

Deryck,

It would be very helpful if you posted the code that is causing
the compiler error.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
D

Deryck

OK. Well the following line will produce the compile error (or syntax error
if I still run the code)

Public ds As New DataSource
dim DonorNumber as long
DonorNumber = 0
' some code...
ds.AddDonation(DonorNumber,"Amount","Date","Source","Application",
"Payment")
'some more code...

The above code is in the userform code.


and then in the datasource class...

Public Sub AddDonation(DonorNumber As Long, Amount As String, donationdate
As String, _
Source As String, Application As String, payment As
String)
'some code

end sub

Thanks,

Deryck
 
C

Chip Pearson

Deryck,

Remove the parentheses in the call to AddDonation. You normally
don't use parens to calls to Sub procedures, only Function
procedures. E.g.,

ds.AddDonation
DonorNumber,"Amount","Date","Source","Application", "Payment"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
D

Deryck

Thanks Chip. I've been struggling because I kept trying to program VBA like
it was C or C++ or Pascal or...something.

Things are working just fine now that I'm doing things VB's way :)

Deryck

PS
I found your website a good Excel resource too.
 
Top