Hi,

Are there any rules for using or not using quotes around true or false.
Witness the following: (Hold the alt key and click the document)

<html>
<head>
<script language=vbs defer>

sub document_onclick()

if d1.contentEditable=true then 'doesn't work
msgbox "d1.contentEditable=true"
else
msgbox d1.contentEditable=true
end if

if d1.contentEditable="true" then 'works
msgbox "d1.contentEditable=""true"" "
else
msgbox d1.contentEditable="true"
end if

if window.event.altKey=true then 'works
msgbox "window.event.altKey=true"
else
msgbox window.event.altKey=true
end if

if window.event.altKey="true" then 'doesn't work
msgbox "window.event.altKey=""true"" "
else
msgbox window.event.altKey="true"
end if

end sub
</script>

</head>
<body>
<div id=d1 contentEditable=true>&nbsp;</div>
</body>
</html>

Re: true false in quotes? by Michael

Michael
Tue Nov 30 18:39:32 CST 2004

These all work for me...

sub document_onclick()

msgbox "typename(d1.contentEditable) is " _
& typename(d1.contentEditable) _
& " with a value of " & d1.contentEditable

if d1.contentEditable then
msgbox "1) d1.contentEditable is true"
else
msgbox "1) d1.contentEditable is not true"
end if

if cbool(d1.contentEditable) = true then
msgbox "2) d1.contentEditable is true"
else
msgbox "2) d1.contentEditable is not true"
end if

if d1.contentEditable = "true" then
msgbox "3) d1.contentEditable is true"
else
msgbox "3) d1.contentEditable is not true"
end if

end sub

--
Michael Harris
Microsoft MVP Scripting



Re: true false in quotes? by beppolainen

beppolainen
Wed Dec 01 06:21:21 CST 2004

The reason why your script is behaving differently is because of the
difference in types of the properties you're accessing.

contentEditable evaluates to a string, as this seems to be a rather
dynamic property. So when you want to check the value of it, you need
to enclose it in quotes and compare it as a string. But I would
recommend you to cast it to a boolean with CBool, CBool("true") =>
True. Be careful though - the cast will fail if the value of the
property cannot be evaluated as a Boolean (i.e. anything else than
true/false).

window.event.altKey, on the other hand, seems to be a real boolean,
which is why you can test it directly with True/False but not
"True"/"False".

If you dig deep enough, you'll prolly find somewhere on MSDN the type
of each property.

Good luck!

Regards,
Johan

"Cassius" <no@spamspam> wrote in message news:<10qpctt6of4gl39@corp.supernews.com>...
> Hi,
>
> Are there any rules for using or not using quotes around true or false.
> Witness the following: (Hold the alt key and click the document)
>
> <html>
> <head>
> <script language=vbs defer>
>
> sub document_onclick()
>
> if d1.contentEditable=true then 'doesn't work
> msgbox "d1.contentEditable=true"
> else
> msgbox d1.contentEditable=true
> end if
>
> if d1.contentEditable="true" then 'works
> msgbox "d1.contentEditable=""true"" "
> else
> msgbox d1.contentEditable="true"
> end if
>
> if window.event.altKey=true then 'works
> msgbox "window.event.altKey=true"
> else
> msgbox window.event.altKey=true
> end if
>
> if window.event.altKey="true" then 'doesn't work
> msgbox "window.event.altKey=""true"" "
> else
> msgbox window.event.altKey="true"
> end if
>
> end sub
> </script>
>
> </head>
> <body>
> <div id=d1 contentEditable=true>&nbsp;</div>
> </body>
> </html>

Re: true false in quotes? by Cassius

Cassius
Wed Dec 01 10:47:39 CST 2004

I see, thanks.