Compare string with integer

  • Thread starter Thread starter hurriance
  • Start date Start date
H

hurriance

I am using excel 2002. I want to compare a string variable with an
integer variable. i.e.

dim i as integer
i=1
dim s as string
s="1"
if i = s then
...........
else
......
end if

however, when I run this macro, a error occur.
how should I compare the variable with two different format ?
 
You have to "coerce" the data in one type to that of the other. Look up
"coerce" in VBA Help for the various Cxxx function.

NickHK
 
doesn't that code work as you want?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top