Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove numbers and symbols from a string. 1

Status
Not open for further replies.

cranebill

IS-IT--Management
Jan 4, 2002
1,113
US
I have company names I am doing comparisons on using soundex function. This works great with the exception that if a number is in the string it errors out.

How can I do this.... convert for example:

3-D Products

to

D Products

Symbols havent caused an error yet... but if i am doing 1 I might as well do both...

Bill

 
Hi,

I'd write a function
Code:
function StripText(str as string) as string
  for i = 1 to len(str)
    b = mid(str, i, 1)
    select case b
      case "a" to "z", "A" to "Z", " "
        StripText = StripText & b
    end select
  next
end function


Skip,

[glasses] [red]Be advised:[/red] It's been reported that a wee psychic is roaming the countryside.
Small Medium @ Large! [tongue]
 
Thanks Skip... Works like a charm...

Now for learning,

Can you give a brief explanation of how this works?

If you dont have time... I understand... Star for you :)
 
With respect to...

1 - how functions work

2 - for...next loop

3 - mid function

4 - select case

???

Skip,

[glasses] [red]Be advised:[/red] It's been reported that a wee psychic is roaming the countryside.
Small Medium @ Large! [tongue]
 
Code:
  for i = 1 to len(str)
    b = mid(str, i, 1)
The mid function returns a string,
b
from the supplied string
str
starting at a position in the supplied string
i
for a specified length
1

So the loop starts with position 1 thru the length of str, for a length of 1 out of str and returns that character to b.

Skip,

[glasses] [red]Be advised:[/red] It's been reported that a wee psychic is roaming the countryside.
Small Medium @ Large! [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top