fortypoundhead.com

GetDigits

Posted On 2012-10-13 by dwirch
Keywords: Get the digits out of a string
Tags: ASP VBScript Tutorial 
Views: 819


Ever wanted to grab all the digits out of a string? This handy little function will do it. Not sure what purpose this would server, but someone requested it, so here it is.

For example, if you have a string value that contains "My n4me3 1s J0e", this function will return a string value containing "4310".

FUNCTION GetDigits(value)

dim strOutput, strDigit, intKount

strOutput = ""

for intKount = 1 to Len(value)

strDigit = Mid(value, intKount, 1)

if (Asc(strDigit) >= Asc("0")) and (Asc(strDigit) <= Asc("9")) then
strOutput = strOutput & strDigit
end if

next

GetDigits = strOutput

END FUNCTION


About the Author

dwirch has posted a total of 175 articles.

You can find more information from dwirch by visiting http://www.derekwirch.com.


Comments On This Post

No comments on this post yet!


Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.


Your IP address is:54.198.147.221

Before you can post, you need to prove you are human. If you log in, this test goes away.



Recent Forum Posts

New security implemented
dwirch posted on July 23, 2017 at about 6:58 in Site News

Fold Code Manager into main KB?
VB6Boy posted on July 22, 2017 at about 14:42 in Site News

Fold Code Manager into main KB?
dwirch posted on July 22, 2017 at about 14:41 in Site News

Fold Code Manager into main KB?
dwirch posted on July 21, 2017 at about 22:46 in Site News

Fold Code Manager into main KB?
dwirch posted on July 20, 2017 at about 7:55 in Site News

Job Spammer: Sam Mallon
dwirch posted on July 18, 2017 at about 18:36 in Spammers