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

How to do type casting at VBScript?

1,716 views
Skip to first unread message

Aaron Bertrand

unread,
Nov 20, 1999, 3:00:00 AM11/20/99
to
if clng(a)=clng(b) then
' say yes
else
' say no
end if

OR

if cstr(a)=cstr(b) then
' say yes
else
' say no
end if

Of course, you could just do this to being with:

a = 1
b = 1

Why do you cast one as a string and the other as a number?

--
- a

Carfield Yim

unread,
Nov 21, 1999, 3:00:00 AM11/21/99
to
How to do type casting at VBScript? e.g.:

Dim a
Dim b


a = "1"
b = 1

if (a = b)
.......

How can I make it legal?


Angus Graham

unread,
Nov 21, 1999, 3:00:00 AM11/21/99
to
Assuming a is always a string and b is always an integer, either:

If val(a)=b then

or

if a=str(b) then

or if a or be can be either

if str(a)=str(b)

Also, probably best to trim just in case so

if trim(str(a)) = trim(str(b))

or

if val(a) =val(b)

Carfield Yim <c813...@comp.polyu.edu.hk> wrote in message
news:3836E65F...@comp.polyu.edu.hk...

0 new messages