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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extract numbers from string

Status
Not open for further replies.

jdttek

Technical User
May 8, 2002
112
US
Hi
I have a text field that contains numbers and letters that I need to extract only the number portion from the string. Length of each string is different, and # of numbers (at end of text) is different, so using right / left functions do not work. Need some way to identify only the numerals (1,2,3...) vs. text characters and return only the numbers. Any ideas or suggestions much appreciated.

Thanks
JDTTEK
 
Try this:

For x = 1 To Len(MyString)
If IsNumeric(Mid(MyString, x, 1)) Then
ParsedString = ParsedString + Mid(MyString, x, 1)
End If
Next x


Hope that helps!

VBAjedi [swords]
 
I just had this a few days ago. Gives a few different directions to go, depending on what your variable starts with and multiple combinations.

thread707-497718
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top