In case the user is allowed to use other characters (for example, the $
sign), then the below function could be useful:
'
' Skips all characters in the input string except
' the first negative-sign, digits, and the first dot
'
Function ParseNumber(ByVal s As String) As Double
ParseNumber = 0#
Dim char As String
Dim i As Integer
Dim digits$
Dim isNegative As Boolean
Dim isPastDot As Boolean
For i = 1 To Len(s)
char = Mid(s, i, 1)
If char >= "0" And char <= "9" Then
digits = digits + char
ElseIf char = "-" Then
If Len(digits) <= 0 Then
isNegative = True
End If
ElseIf char = "." Then
If Not isPastDot Then
isPastDot = True
digits = digits & "."
End If
End If
Next i
ParseNumber = CDbl(digits)
If isNegative Then
ParseNumber = 0 - ParseNumber
End If
End Function