Avatar of sasllc
sasllcFlag for United States of America

asked on 

How to replace non-numeric characters in a text string?

In vb.net, I am importing a phone number text field, and I need to output it as a field of all numerics.  Quite often the input will have hyphens that I need to eliminate, so I've been handling that with:
StrJ=StrJ.Replace("-", "")    which works fine.

But now I find that all kinds of other stuff is coming in, such as parentheses, asterisks, extra spaces, and even letters.  Is there an easy way to eliminate any and all characters that are not numeric?  I need to have a clean output that is nothing but the digits in the phone number.

Visual Basic Classic

Avatar of undefined
Last Comment
santosh26676
ASKER CERTIFIED SOLUTION
Avatar of thekng
thekng

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of sasllc
sasllc
Flag of United States of America image

ASKER

OK, I understand the concept (not isnumeric), but I need more detail on how to implement it (I'm new at vb).

Say I've got this string coming in that I'm calling StrJ, and it contains: 1-731-8227 (Joe)

And I want to end up with: 17318227

It's fine with me if it ends up still in StrJ, or in a different string name if that's easier.

With that in mind, how would I implement your concept above?  If possible, please give me a detailed example...

SOLUTION
Avatar of Shauli
Shauli

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of AlexFM
AlexFM

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of Dabas
Dabas
Flag of Australia image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of dancebert
dancebert

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of Dave
Dave
Flag of Australia image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of santosh26676
santosh26676

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Visual Basic Classic
Visual Basic Classic

Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.

165K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo