AddEvent OR Control issue

enonod

Well-Known Member
Licensed User
Longtime User
I am receiving syntax error 'missing parameter' for the following...

for i=1 to 6
AddEvent(Control("lNum"&i,NumUpDown),ValueChanged,"Adjust")
next

I am baffled as to what is missing. I added NumUpDown but it did not solve it.

Where have I gone wrong please?
 

enonod

Well-Known Member
Licensed User
Longtime User
Thanks for that. Yes there should be no 'l' on the front, but removing it gives the error that it is not set to an instance of the object.
The object name is for example Num1 or Num2 etc.
The object referred to was placed on the form, is that OK or must it be created?

Further help appreciated
 

agraham

Expert
Licensed User
Longtime User
AddEvent wants the control name as a string not as a control reference. It is enough to do this

AddEvent("Num" & i, ValueChanged, "Adjust")

If you do ever need to get a control dynamically instead of Control use the new syntax introduced in v6.90 (see What's New in the help)

NumUpDown("Num" & i)

This lets the IDE give you AutoComplete and popup help for the control.
 
Y need to make sure you have six NumUpDown controls Num1 through Num6
and that sub Ajust does exist.
The aforementioned should make you happy :)
 

enonod

Well-Known Member
Licensed User
Longtime User
@nicholasWhite: Thank you. I do have all the controls etc. The problem was solved by Agraham.

@agraham: Thank you for the solution.
 
Top