Is there a way to pass condition of an IF statement as parameter of a function call?

G

Guest

Heloe
I would like to be able to pass a condition of an IF statement as parameter as follow


aStr=†(A=1) and (B=2)â€
if aFunc(“aStrâ€) then
….

End if

and then the fuction process this and return true and false. This is not how i am going to use this just an example of how to send the condition and process it at the called function.

Private sub aFunc (ByVal aCond as string) as Boolean
‘ not suggesting it has to be String

If (aCond) then
Return true
Else
Return false
End if

End sub

How would I do that?
Thanks
Lisa
 
H

Herfried K. Wagner [MVP]

* "=?Utf-8?B?TGlzYSBKLg==?= said:
I would like to be able to pass a condition of an IF statement as parameter as follow


aStr=� (A=1) and (B=2)�
if aFunc(“aStr�) then
….

End if

and then the fuction process this and return true and false. This is not how i am going to use this just an example of how to send the condition and process it at the called function.

Private sub aFunc (ByVal aCond as string) as Boolean
‘ not suggesting it has to be String

If the condition doesn't need to be a string, why not type in the
condition directly?
 
G

Guest

I have function that based on the condition need to perform different things and condition could be many different things I cannot anticipates all the conditions in the function
Lis
 
B

Bill Nicholson

You need to use the Eval( ) method in order to parse these constructs at
run-time.

Check this out: ms-help://MS.VSCC/MS.MSDNVS/script56/html/vsfctEval.htm

In VB 6 there was a Script Control that implemented the Eval( ) method but
I've not looked for the equivalent control in Dot Net.


Bill Nicholson
Cincinnati, OH USA

Lisa J. said:
Heloe
I would like to be able to pass a condition of an IF statement as parameter as follow


aStr=" (A=1) and (B=2)"
if aFunc("aStr") then
..

End if

and then the fuction process this and return true and false. This is not
how i am going to use this just an example of how to send the condition and
process it at the called function.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top