Results 1 to 10 of 10

Thread: 5=5=5

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    247
    How come the first msgbox returns false and the second msgbox returns true?>

    Code:
      MsgBox 5 = 5 = 5
      MsgBox 5 = 5
    Mako Shark
    Great White

  2. #2
    Addicted Member jeroenh's Avatar
    Join Date
    Aug 2000
    Location
    Rotterdam, Holland
    Posts
    201
    I don't know for sure but I think it has to do with the fact that VB doesn't understand your zomparison.

    I have been trying a couple of things and it's with all the lines where there more then one "=" symbol. There where there was one, it worked.

    It's just a guess, but I could be right?:Confused:
    Catch you later,

    Jeroen Hoekemeijer
    Code:
    If 1 = 2 Then MajorError

  3. #3
    Addicted Member jeroenh's Avatar
    Join Date
    Aug 2000
    Location
    Rotterdam, Holland
    Posts
    201
    I don't know for sure but I think it has to do with the fact that VB doesn't understand your zomparison.

    I have been trying a couple of things and it's with all the lines where there more then one "=" symbol. There where there was one, it worked.

    It's just a guess, but I could be right?
    Catch you later,

    Jeroen Hoekemeijer
    Code:
    If 1 = 2 Then MajorError

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,092
    maybe it has something to do with this:
    5 = 5 is true
    so
    5 = 5 =5
    is like saying:
    True = 5
    I don't know, maybe.

  5. #5
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    I think it only does simple equations? Like there are only 2 parts to an equation side1 and side2

  6. #6
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    The reason why the second returns true is because

    5=5 -----> True

    msgbox 5=5 ---------> true




    The reason why the first returns false is because it goes from left to right.


    First it compare the first two.

    5=5 -----> True

    Next, it takes the result of that and compare to the rest.

    True=5---> False

    msgbox 5=5=5 ---------> false



    if you have done it like

    msgbox 5=5=true ---------> True
    msgbox true=5=5 ---------> False

    Chemically Formulated As:
    Dr. Nitro

  7. #7
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,092

    Hey, cool I was right!

    Yeah for me!

  8. #8
    Fanatic Member
    Join Date
    Jun 1999
    Location
    California, USA
    Posts
    662
    Wait a sec. Nonzero values are evaluated as True.

    True = (True = 5)

    According to vb's rules of boolean logic, ((5=5)=5) should return True.

    when you convert True to in integer you get -1; false you get 0.

    a = 5
    If a Then
    Beep
    End if

    The system would beep. VB violates it's on boolean logic rules. No problem, since I would just use the keyword True or False instead of an expression that ALWAYS returns true or false.

    $0.02

  9. #9
    Lively Member flint's Avatar
    Join Date
    Oct 2000
    Posts
    67
    Wow agent ... you have been "burning up" the internet.

    hehe. I know (bad joke). I hope that your house fire wasn't a great loss.

    Cordially,
    Flint

  10. #10
    Guest
    OK, heres the solution

    VB's "favorite" definition of True (numerically) is -1

    so

    msgbox -1 = -1 = -1 'returns "True"

    because -1 does equal -1
    thus
    -1 = true

    This definition only seems to apply to explicit constants (if you actually hard code the numbers into a comparison) but things like

    len("xyz") 'will return an expression that can be used in a boolean situation.


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