Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default 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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 233
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Evaluating an expression...

Thanks so much. Works great!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Evaluating division by zero Shams Excel Worksheet Functions 10 April 14th 08 10:24 PM
VBA for Evaluating Integrals brett4098[_3_] Excel Programming 0 November 12th 04 08:42 PM
Evaluating Week No. MahaRaj Excel Programming 8 July 25th 04 02:06 PM
Evaluating a cell Phillip2001 Excel Programming 2 December 9th 03 03:44 AM
Evaluating a range Mike[_58_] Excel Programming 1 November 20th 03 02:29 PM


All times are GMT +1. The time now is 10:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"