locked
cbool ( expression and value) RRS feed

  • Question

  • User-2082385491 posted

    Hi All,

    I have an asp page which contain the following code

    myvar = Cbool(id and 2048)

    I don't understand what does it mean.

    Thursday, September 4, 2014 12:37 AM

Answers

  • User1176121428 posted

    Hi nirmal2014,

    Thanks for your post.

    cbool ( expression and value)
    this should be VBScript.

    The CBool function converts an expression to type Boolean.The expression must be a numeric value.

    please check this:http://www.w3schools.com/vbscript/func_cbool.asp

    Hope this can be helpful.

    Best Regards,

    Eileen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 5, 2014 3:03 AM

All replies

  • User397347636 posted

    It's taking the bitwise 'and' of 'id' and 2048 - the result is an integer.  It then converts that to a boolean via 'CBool'.  This is terrible code - why convert an integer to a boolean?  Only the integer '0' will convert to the boolean value 'True' - all others will convert to 'False'.  Totally idiotic code.

    It would have been far clearer to code "myvar = (id And 20048) = 0" than this crap.

    Thursday, September 4, 2014 12:42 AM
  • User1176121428 posted

    Hi nirmal2014,

    Thanks for your post.

    cbool ( expression and value)
    this should be VBScript.

    The CBool function converts an expression to type Boolean.The expression must be a numeric value.

    please check this:http://www.w3schools.com/vbscript/func_cbool.asp

    Hope this can be helpful.

    Best Regards,

    Eileen

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 5, 2014 3:03 AM