Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Boolean Variable

5 views
Skip to first unread message

Richard Pidcock

unread,
Aug 7, 2003, 11:38:03 AM8/7/03
to
How do I dimension a Boolean variable in a VB Script?

Tom Lavedas

unread,
Aug 7, 2003, 11:55:14 AM8/7/03
to
Dim bVariable ' as boolean

All variables are of type Variant in scripting, so you
can't actually create a boolean (notice informational
comment at end of DIM statement). It can only be
subtyped - and then only by typecasting using an
equivalence statement, as in ...

bVariable = False ' now its a variant, subtype boolean

If you're having troubles with a type mismatch from a roll-
your-own control, it can only be fixed by revising your
control to return only variants.

Tom Lavedas
===========

Joe Earnest

unread,
Aug 7, 2003, 12:04:53 PM8/7/03
to
Hi,

"Richard Pidcock" <richard...@eds.com> wrote in message
news:0cd301c35cf9$e3b52ee0$a501...@phx.gbl...


> How do I dimension a Boolean variable in a VB Script?

All VBS variables are variants, and there are no initial type declarations.
When used in a Boolean operation, the initial Empty assignment will be
coerced to False (either dual-state or long integer numeric 0). Subtypes
are created when assigned. You can assign dual-state booleans directly,
using the True or False functions, comparisons, etc. The vbTrue and vbFalse
constants are actually long integer subtype numeric booleans, set to 0
or -1. If you need to insure that you have a boolean dual-state variable
for other assignments, use CBool.

Joe Earnest


John Ford

unread,
Aug 7, 2003, 12:07:51 PM8/7/03
to
Dim bolMyFlags(9) ' zero-based array w/10 elements
For Each bolTemp in bolMyFlags
bolTemp = False
Next

--
jcf


"Richard Pidcock" <richard...@eds.com> wrote in message
news:0cd301c35cf9$e3b52ee0$a501...@phx.gbl...

0 new messages