Results 1 to 2 of 2

Thread: vb casting boolean

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2006
    Posts
    3

    vb casting boolean

    can any one help me with the following issue:

    when we cast boolean variable to integer true gets the value -1 instead of 1
    eg:
    dim a as boolean
    dim b as integer

    a= true
    b=a
    msgbox(b)

    we will get -1 why it is so ?

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: vb casting boolean

    Welcome to VBForums!

    You get -1 because that is the value of True.

    If you want to have 1 instead (and 0 for False) you can simply use the Abs function, eg:
    VB Code:
    1. b = Abs(a)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width