![]() |
Evaluating an expression...
I have a function with parameters pay99,pay00,pay01,pay02, etc., and in
my code I have declared a variable named cParam. If cParam equals the string "pay02", what function or expression do I use on cParam to get the value of parameter pay02? Many thanks. |
Evaluating an expression...
A large case statement:)
No but seriously, if you have a function that has a whole slew of parameters of the same type/meaning, you need a paramarray, check XL help to see how that works. From there you can say Myval = PrmPay(99) to get the 99th parameter. Besides this advantage, it also keeps the parameters optional. If you only need 88 that would work without any problem. DM Unseen |
Evaluating an expression...
I don't believe there is an arglist type functionality as in C, so I believe
you would have to hard code a case statement Select Case cParam Case "pay99" s = pay99 Case "pay00" s = pay00 Case "pay01" s = pay01 Case "pay02" s= pay02 Case Else s = "" End Select Another approach would be to use a paramarray and not define you arguments. Function MyFunction(ParamArray v()) cParem = 2 MyFunction = v(cParem - 1) End Function Sub Tester1() MsgBox MyFunction("A", "B", "C", "D") End Sub the message box returns B -- Regards, Tom Ogilvy "CR" wrote in message oups.com... I have a function with parameters pay99,pay00,pay01,pay02, etc., and in my code I have declared a variable named cParam. If cParam equals the string "pay02", what function or expression do I use on cParam to get the value of parameter pay02? Many thanks. |
Evaluating an expression...
Thanks so much. Works great!
|
All times are GMT +1. The time now is 02:45 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com