Discussion:
Stripping off a string
(too old to reply)
Ato_zee
2003-10-30 07:43:50 UTC
Permalink
I have strings of form
A Customer (UK)
Another Customer (USA)
and want to strip off the country code that is in parenthesis.
That is remove the left parenthesis and all after it.
I want to do a string comparison on name only, since the country code may be
in one string and not the other.
Can anyone point me towards a method?
Using VB 6.0.

Many thanks for any replies.
Tom Lake
2003-10-30 08:00:24 UTC
Permalink
Post by Ato_zee
I have strings of form
A Customer (UK)
Another Customer (USA)
and want to strip off the country code that is in parenthesis.
That is remove the left parenthesis and all after it.
I want to do a string comparison on name only, since the country code may be
in one string and not the other.
Can anyone point me towards a method?
Using VB 6.0.
Many thanks for any replies.
to strip off the characters do this:

s$ = "Another Customer (USA)"
s$ = Left(s$, Instr(s$ & " (", "(") - 2)

then s$ will be "Another Customer" The reason for the & " (" is to avoid an
error if there's no left parenthesis in the string to begin with.
--
Tom Lake

Experience keeps a dear school but fools will learn in no other - Poor
Richard's Almanack
J French
2003-10-30 12:54:21 UTC
Permalink
VB6 has InStrRev()
Post by Ato_zee
I have strings of form
A Customer (UK)
Another Customer (USA)
and want to strip off the country code that is in parenthesis.
That is remove the left parenthesis and all after it.
I want to do a string comparison on name only, since the country code may be
in one string and not the other.
Can anyone point me towards a method?
Using VB 6.0.
Many thanks for any replies.
Ato_zee
2003-10-31 19:32:51 UTC
Permalink
Many thanks for the replies. The construct

DBName(I) = LCase$(DBName(I))
DBName(I) = Left$(DBName(I), InStr(DBName(I) + " (", "(") - 1)
DBName(I) = LTrim$(RTrim$(DBName(I)))

Both sides of the compare works fine.

Tried copying string from a larger to a smaller no of chars
array, to truncate the string didn't work, and putting the string
into an array to hold each character in it's own cell, then
parsing and copying to substitute spaces where needed
was getting a bit hairy.

Loading...