This function returns the numeric value string within another string.
This function returns the numeric value string within another string.
API Declarations
'Start the Standard exe project
'Load a form
'Add a text box name text1.txt on a form
'Please note that the For Loop is start to search the from the first char
'to the last char in the string until the values are found.
Rate This function returns the numeric value string within another string.
(1(1 Vote))
Dim SearchString, c1, c2, c3 As String
Dim FoundNumber As Integer
Dim i As Integer
SearchString = "Look for a number12345in this string"
'Given a For Loop to search for numeric value
For i = 1 To Len(SearchString) - 2
c1 = Mid(SearchString, i, 1)
c2 = Mid(SearchString, i + 1, 1)
c3 = Mid(SearchString, i + 2, 1)
If c1 >= "0" And c1 <= "9" Then
If c2 >= "0" And c2 <= "9" Then
If c3 >= "0" And c3 <= "9" Then
FoundNumber = 1
Exit For
End If
End If
End If
Next
If FoundNumber = 1 Then
Text1.txt = Val(Mid(SearchString, i))
Else
Text1.txt = "Found Nothing"
End If
End Sub
'When the Form is loaded, the text box will show only the group of numeric
'number in the Search String.
This function returns the numeric value string within another string. Comments
No comments yet — be the first to post one!
Post a Comment