Jump to content

[solved] Why are these different?


Recommended Posts

If "04" == 4 Then
 MsgBox(0, '==', "TRUE")
Else
 MsgBox(0, '==', "FALSE")
EndIf

If "04" = 4 Then
 MsgBox(0, '=', "TRUE")
Else
 MsgBox(0, '=', "FALSE")
EndIf

These give different results. Will someone tell me why?

"04" is a string and 4 is an integer.

A string is an array of chars, right?

'=' is the assignment operator and '==' is the equality operator.

When I state "04" = 4, then am I not using the assigment operator?

And if so then how am I assigning 4 into "04".

Unless:

Global $string = "04" ; $string stores "04"

MsgBox(0, '', $string)

"04" = 4

MsgBox(0, '', $string) ; now $string stores the char '4'?

Ok, no that isn't it...

Edited by jaberwocky6669
Link to comment
Share on other sites

I originally posted my question there but they told me that I was actually talking about something slightly different, and so I posted a new thread. If I can find my answer there then I will delete this thread (or ask it to be deleted).

Link to comment
Share on other sites

I originally posted my question there but they told me that I was actually talking about something slightly different, and so I posted a new thread. If I can find my answer there then I will delete this thread (or ask it to be deleted).

Oh duh, I totally overlooked the answer.

Link to comment
Share on other sites

I dusted off my dusty, rusty helpfile:

'==' Tests if two strings are equal. Case sensitive. The left and right values are converted to strings if they are not strings already. This operator should only be used for string comparisons that need to be case sensitive.

Edited by jaberwocky6669
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...