I have a query with a text field similar to the following:
Fail
<24
>24.6
Fail
>100
<45
>100
Fail
77
59.9
I am using the following code to extract numbers from the text but the decimals are removed. Problem is I would like to keep all decimals in the numbers.
Public Function getNum(myField)
Dim s As String, l As Long, x As String
If Len(Trim(Nz(myField, ""))) = 0 Then
getNum = myField
Exit Function
End If
For l = 1 To Len(myField)
x = Mid(myField, l, 1)
If (x >= "0" And x <= "9") Then
s = s & x
End If
Next l
getNum = s
End Function
Can anyone suggest how to alter the code or a better way?
Fail
<24
>24.6
Fail
>100
<45
>100
Fail
77
59.9
I am using the following code to extract numbers from the text but the decimals are removed. Problem is I would like to keep all decimals in the numbers.
Public Function getNum(myField)
Dim s As String, l As Long, x As String
If Len(Trim(Nz(myField, ""))) = 0 Then
getNum = myField
Exit Function
End If
For l = 1 To Len(myField)
x = Mid(myField, l, 1)
If (x >= "0" And x <= "9") Then
s = s & x
End If
Next l
getNum = s
End Function
Can anyone suggest how to alter the code or a better way?