Reputation: 23
I have a condition in a variable. I try to check if the condition is true or not.
On below example I'm assigning a condition "1=1" (which is true) to variable MyCond. I'm trying to check if the condition in MyCond is true. Do you please help?
Sub Test()
MyCond = "1=1"
If MyCond = True Then
MsgBox "That is true"
Else
MsgBox "That is false"
End If
End Sub
Upvotes: 2
Views: 175
Reputation: 35863
You can use Evaluate(MyCond)
:
Sub Test()
Dim MyCond As String
MyCond = "1=1"
If Evaluate(MyCond) Then
MsgBox "That is true"
Else
MsgBox "That is false"
End If
End Sub
Upvotes: 5
Reputation: 96781
Just construct a Boolean
Sub test()
Dim myCond As Boolean
myCond = (1 = 1)
MsgBox myCond
End Sub
Upvotes: 0