akohan
asked on
How to change the result of a function?!
Hello group,
I'm writing a function that reterives number of avaiable macros in an Excel workbook. This works fine but sometimes I need to have this functions the number of avaiable macros in a Workbook and sometimes I want it to return the list or namesof them.
How can I write a functions that its return value could switch from string to integer?
Your help will be appreciated.
Ak
In VB6 ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
akohan...Why not just always return an array of string and then calculate the count from that array?
Or you could return a Collection object with the names in it...
Or you could return a Collection object with the names in it...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry for later response, have been busy. I know guys you are right it is a bad idea however, I'm going to check all the answers and give you a feedback soon.
As you mentioned, right I believe retruning an array or collection is what we do in other languages as well.
I truly appreciate your help and will get back to you soon.
Thanks,
ak
ASKER
Thanks to all.
Regards,
ak
If you don't use OPTION EXPLICIT to force you to declare your variables, then the type of variable returned will be determined by the contents of the variable.
So if you return an alphanumeric value, it will be string, but if you return a whole number it will be an integer.