A long time ago I wrote this function in response to a similar post:
'------ start of code ------
Function fncZonedToNumber( _
ZonedValue As Variant, _
Optional DecimalPlaces As Integer = 0) _
As Variant
Dim strValue As String
Dim strLast As String
If IsNull(ZonedValue) Then
fncZonedToNumber = Null
ElseIf VarType(ZonedValue) <> vbString Then
fncZonedToNumber = CVErr(5) ' invalid argument
ElseIf Len(ZonedValue) = 0 Then
fncZonedToNumber = Null
Else
strLast = Right(ZonedValue, 1)
strValue = Left(ZonedValue, Len(ZonedValue) - 1)
If InStr(1, "0123456789", strLast, vbBinaryCompare) Then
strValue = strValue & strLast
ElseIf InStr(1, "ABCDEFGHI", strLast, vbBinaryCompare) Then
strValue = strValue & Chr(Asc(strLast) - 16)
ElseIf InStr(1, "JKLMNOPQR", strLast, vbBinaryCompare) Then
strValue = "-" & strValue & Chr(Asc(strLast) - 25)
ElseIf StrComp(strLast, "{", vbBinaryCompare) = 0 Then
strValue = strValue & "0"
ElseIf StrComp(strLast, "}", vbBinaryCompare) = 0 Then
strValue = "-" & strValue & "0"
Else
fncZonedToNumber = CVErr(5) ' invalid argument
Exit Function
End If
If DecimalPlaces = 0 Then
fncZonedToNumber = Val(strValue)
Else
fncZonedToNumber = Val(strValue) / (10 ^ DecimalPlaces)
End If
End If
End Function
'------ end of code ------
In your case, you would pass the value 2 for the DecimalPlaces argument:
?fncZonedToNumber("1237B", 2)
123.72
?fncZonedToNumber("4567J", 2)
-456.71
--
Dirk Goldgar, MS Access MVP
Access tips:
www.datagnostics.com/tips.html
(please reply to the newsgroup)
"Sam" <(E-Mail Removed)> wrote in message
news:34bac5c7-3746-4039-84e5-(E-Mail Removed)...
I have sample values listed below in a field called AMT1.
002527}
0024763
002349Q
002052}
0019258
001645K
001237B
004567J
and I need to convert these values to the true number as exampled
below:
As an example the data below will convert a signed numeric value for a
specific field.
ï‚§ Sample AMT1 = 1237B
This is amount would need to be converted as 123.72
ï‚§ 2nd Sample AMT = 4567J
This is amount would need to be converted as 456.71- or (456.71)
I have a chart of the ascii character to the number value.
What would be the easiest way to convert these values?
Thanks for your help!!!!