Two issues here I can't explain.
Issues 1
-----------
I have a class defined in say in module "myclass"
One of the methods is say method1, which has been declared as
Public sub method1(byref parm1 as long, byref parm2 as string)
Also in a test module I test the method1 as follows:-
***********************************
I get a "compile error expected ="
Which seems to mean I have to assign a var to capture the return value from method1....but I haven't defined the sub to return a value (that's called a function)??
If I do assign a var to = the return value (i.e. var = method1...), the syntax error disappears but I get a runtime error - "Expecting a function or variable" as there is no return value from the method (i.e. not a function). Only way around this is to declare the method as a function and give it a return value.
Also, the EXACT SAME setup above but with just 1 parm (i.e. defined method1 to take JUST parm1 ) everything works as it should using a sub and not a function.
In summary, it would appear I can only declare a sub method if it takes only 1 parm, otherwise I have to declare a function - what am I missing or why is vba behavin g this way? Perhaps try it in case it's something to do with my setup only.
Issue 2
---------
Stumps me even more involving collections and number to string conversions
Here we go.....code is:-
later I try to access an nclass object from the collection via the key ...
mycol(data(1,1)) - gives me a subscription range error.
Ah ha this means data(1,1) must return the number stored as a number, not a string. So to get around this I use CStr(data(1,1))....although it doesn't seem to return a string either or at least I get another range error.
I've also tried Str which doesn't resolve issue either.
If I use mycol("<actual number>") this works.
So why isn't the CStr or Str doing its' conversion work or how else can I get around this?
Any help much appreciated.....
Thanks,
Bookmarks