Peter said:
I have a string in form "abcdefg 123,55 ijklmn"
Now I want get only the number 123,55 within the string !!
Is there any function available in VB.NET ??
I have once written this code based on a sample I found somewhere on the
web in VB6. Maybe you can convert it to .NET:
\\\
Private Function PurgeNumericInput(ByVal strString As String) As Variant
Dim blnHasDecimal As Boolean, i As Integer
Dim s As String
strString = Trim$(strString)
If Len(strString) = 0 Then
Exit Function
End If
For i = 1 To Len(strString)
Select Case Mid$(strString, i, 1)
' Is this character a number?
Case "0" To "9"
' Add it to the string being built.
s = s & Mid$(strString, i, 1)
' The char is a decimal.
Case ".", ","
If Not blnHasDecimal Then
blnHasDecimal = True
s = s & "."
End If
End Select
Next i
PurgeNumericInput = Val(s)
End Function
Private Sub Main()
Call MsgBox( _
PurgeNumericInput( _
"$44E.mbedded letters and spaces 33 a few more " & _
"pieces of garbage .9" _
) _
)
End Sub
///
It's very quick and dirty, BTW.