Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
cbool & eval
#1
Solved: 11 Years, 4 Months, 3 Weeks ago
Hi,
Can anyone explain the difference between cbool and eval func with example?

Thanks in advance...
Reply
#2
Solved: 11 Years, 4 Months, 3 Weeks ago
In vbscript x = y can be interpreted two ways. The first is as an assignment statement, where the value of y is assigned to x. The second interpretation is as an expression that tests if x and y have the same value. We use Eval method if x=y result is True; if they are not, the result is False.

And CBool method test, if expression x=y evaluates to a nonzero value, returns True; otherwise, it returns False.

Code:
Dim A, B, Check , c, D
A = 10: B = 5:  c=5 : D=10      ' Initialize variables.

If Eval("A = B") Then
         MsgBox "Congratulations! A is equal to B"
      Elseif Eval("C=B") then
    Msgbox "Congratulation! B and C are equal"
End If

'Cbool example

Check = CBool(A = B)   ' Check contains False.
msgbox Check
A = 10                  ' Define variable.
Check = CBool(A)       ' Check contains False.
msgbox check
check = CBool(C=B) ' Check contains True.
msgbox check
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Technical Support during 14 day eval mundorff 1 1,889 09-01-2009, 04:51 PM
Last Post: Saket
  Issues with QTP 10 eval version amourack2 2 4,853 06-24-2009, 10:22 PM
Last Post: amourack2

Forum Jump:


Users browsing this thread: 1 Guest(s)