Friday, December 3, 2010

Numeric digits from String

Function to get all the numbers available in passing String, if you want to get numbers separately like

eg: Baba 205 Fakruddin passed out in 2006"
following function returns like 2052006...

If you want to separately, do some work on below function and update... we can get it by spliting words with " " then try to get the numbers from each word. The loop will be rotate for every word length.

I've given a hint... you'll get it easily.

'************************   Code Starts here    **************************

Dim var

var = inputbox("Enter the string with any numeric value", "Alpha Numeric", "Baba205Fakruddin")

Function Get_No_FromString(var)

len_var = len(var)


For i=1 to len_var

cha =mid(var,i,1)

If isnumeric(cha) Then '1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9)

bln = bln&cha

print bln

End If


print "The digits in string"&bln


End Function

No_in_String = Get_No_FromString(var)

msgbox "The digits available in string"&No_in_String

"A good threat is worth a thousand tests" - Boris Beizer

No comments:

There was an error in this gadget