Using Len & IsNumeric Funtions
strText = "QTP123Sreenu456Blog"
iLen = Len(strText)
For i=1 To iLen
iChar = Mid(strText,i,1)
If IsNumeric(iChar) Then
strOutput = strOutput & " " & iChar
End If
Next
MsgBox strOutput
iLen = Len(strText)
For i=1 To iLen
iChar = Mid(strText,i,1)
If IsNumeric(iChar) Then
strOutput = strOutput & " " & iChar
End If
Next
MsgBox strOutput
Without using any
built-in functions
strText = "QTP123Sreenu456Blog"
Set oRegExp = New RegExp
oRegExp.Pattern = "\d"
oRegExp.Global=True
Set oItems = oRegExp.Execute(strText)
For i=0 To oItems.Count-1
strOutput = strOutput & " " & oItems(i)
Next
For loop above can also be written as below
For Each oItem In oItems
strOutput = strOutput & " " & oItem.Value
Next
oRegExp.Pattern = "\d"
oRegExp.Global=True
Set oItems = oRegExp.Execute(strText)
For i=0 To oItems.Count-1
strOutput = strOutput & " " & oItems(i)
Next
For loop above can also be written as below
For Each oItem In oItems
strOutput = strOutput & " " & oItem.Value
Next
MsgBox strOutput
No comments:
Post a Comment