You can't. You need to evaluate a string as if it were code, and there is
no easy way to do that. You would need to either parse it out yourself, or
there are ways you can write, compile and execute code at runtime (slow and
not so pretty).
In your case, I am not sure why you are turning things into Integers, just
to then turn them back into a string during concatentation?
The easiest way to do this in your particular case would be to write a
function that took as parameters the values to compare, and the operator.
Then just have a case statement on the operator, and perform the appropriate
comparison with the operands. Return the result of the comparison.
Also, you should turn Option Strict On. That would prevent these errors at
compile time, rather then at runtime. You should always keep this option
turned on.
"hazz" <gr*********@nospamcomcast.net> wrote in message
news:e5****************@tk2msftngp13.phx.gbl...
I get an InvalidCastException "Cast from string "6<5" to type 'Boolean is
not valid.
for
If (CInt(objBuyInfo.Budget) & " " & arrRuleList(i).operator & " "
& CInt(arrRuleList(i).LeadMemberValue)) Then
where arrRuleList(i).operator = ">"
and CInt(objBuyInfo.Budget) = 6
and CInt(arrRuleList(i).LeadMemberValue) = 5
The quickwatch shows "6 < 5" {String} Object
How can I create a legitimate expression from this property values?
Thank you,
-hazz