Class method will not accept parameters

R

redhorse

I have created a custom class and I am able to get property procedures to
work as well as any methods that don't require any parameters. However, I
cannot seem to get a method that requires parameters to work at all.

I dhave the following methods in a class module:

Public Sub INCF()
Me.Value = currentValue + 1 'currentValue is a private property of the
class
End Sub

Public Sub BSF(ByVal i as integer)
Me.Value = i
End Sub

Note: the property procedure Value works in every other method as well as on
an instance of the class.

I can successfully call the INCF method on an instance of the class as
follows:
Reg0.INCF

When I try to use the BSF method on an instance of the class as follows:
Reg0.BSF(7)
IntelliSense will pop up and correctly show the parameters. But, after type
them in and hit enter, the code editor will separate the parenthesis from the
method name as if it is an invalid function:
Reg0.BSF (7)
If I run the code, it will generate an error stating "Invalid procedure call
or argument."

I have searched high and low for an answer to this problem, but I just can't
figure out what I am doing wrong. Everywhere I have looked seems to confirm
that I am declaring the method and calling it properly. I must be missing
something simple, but I can't for the life of me figure out what it is.
 
R

redhorse

A couple extra pieces of information:

(1) When executing code in the immediate window, I can get the BSF method to
work with parameters.

(2) The problem is in a code module for a slide (under Microsoft PowerPoint
Objects in the VBA Project window). In that module, I can call methods
without parameters without any problem. When I try to use the BSF method
with parameters, I get the problem described in my previous post.

Why can I call a method without parameters but not one that does have them?
Do I need to declare the method differently?
 
R

redhorse

I wish I could edit my previous posts.

I forgot to mention that the the class is instantiated as a global variable
in a separate code module.
 
R

redhorse

Yet more information:

Even if I try to call the BSF method in the same code module where the class
was instantiated, I get the same problem.

This one has me completely baffled!
 
R

redhorse

Steve,

Thanks for the help. The strange thing is that after I walked away for a
few minutes and returned to try again without making any changes, it all
started to work, even though the function name and parenthesis were still
separated.

I tried "Reg0.BSF 7", but that generated errors too.

Adding the "Call" keyword in front seemed to fix everything.

Wierd...

Thanks again.
 
Top