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

Convert numeric part of text to number

5 views
Skip to first unread message

davegb

unread,
Aug 22, 2005, 5:50:47 PM8/22/05
to
I am combining 2 lists in 2 columns in XL. The index in both lists is
in the format: 01-Adams. There is one for each county in the state. I
want to know how to convert the 01 text part to a numeric value to
compare to another one and determine where they should be in a table.
If I do a

strOrigCtyNo = Right(strOrig, Len(strOrig) + 2)

I believe it will give me the first 2 characters of the code. How do I
convert them to an integer constant to compare them, or do I even have
to? If I remember right from my old programming days, comparing numbers
in ASCII sometimes gives different results from comparing numbers. Is
that still true in VBA? What is the best way to proceed here?
Thanks again!

Jim Thomlinson

unread,
Aug 22, 2005, 6:10:06 PM8/22/05
to
in VBA there are functions CInt, CDbl, ... which convert text to value. You
should be albe to use CInt to convert teh first two digits to an number.
--
HTH...

Jim Thomlinson

davegb

unread,
Aug 22, 2005, 6:34:00 PM8/22/05
to

Thanks, Jim!

Tom Ogilvy

unread,
Aug 22, 2005, 6:55:36 PM8/22/05
to
if the first two digits are on the left side of the string, I don't think
this is what you want:

strOrigCtyNo = Right(strOrig, Len(strOrig) + 2)


strOrigCtyNo = Left(strOrig,2)

a way to do the conversion would be

Dim lngOrigCityNo as Long
lngOrigCityNo = Left(strOrig,2)

--
Regards,
Tom Ogilvy

"davegb" <dav...@safebrowse.com> wrote in message
news:1124750040.5...@o13g2000cwo.googlegroups.com...

davegb

unread,
Aug 23, 2005, 4:20:38 PM8/23/05
to
Thanks again, Tom!

0 new messages