Dim mystring, myLength
mystring = “abhikansh567st1239test”
myLength = Len(mystring)
mystring = “abhikansh567st1239test”
myLength = Len(mystring)
For i = 1 To myLength
If Asc(Mid(mystring, i, 1)) <> 32 Then
If Asc(Mid(mystring, i, 1)) >= 48 And Asc(Mid(mystring, i, 1)) <= 57 Then
myNumber = myNumber & Mid(mystring, i, 1)
End If
Else
msgbox(“no numeric”)
End If
Next
msgbox(myNumber)
hello ,
can u explain what is need of values in loop statements . i.e ,, 32, 48 and 57 . and how it'll extract numbers in a alphanumeric string..
32, 48 etc are index for ascii character. just try to run the code and see how its working.
with out using functions and loop statement how can we get the number from alpha numerics
What if the length of the string is 1000 ? How to get position of the numbers alone using regular expression?
str = "abhikansh567st1239test"
Set regEx = New RegExp
regEx.pattern="d+"
regEx.Global = True
Set obj = regEx.Execute(str)
For i=0 to obj.count-1
msgbox obj.item(i)
Next
Hi by using Regular expressions also we can extract a number from alphanumeric text string.i any one have doubts please let me know
Set r=new regexp
r.pattern="[0-9]+"
r.global=true
x="koteswararao423"
Set y=r.execute(x)
For each z in y
msgbox z