Hi Jim,
This function - author unknown - has been posted in the newsgroups a few
times. Start by importing the signed fields into a text field; then add
a number field to the table; next use fncZonedToNumber in an update
query to populate the number field; and finally delete the text field.
You say "signed dollar fields": if this means the last two digits in the
signed field represent cents, your update query will need to divide the
values returned by fncZonedToNumber by 100.
Function fncZonedToNumber(ZonedValue As Variant) 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
fncZonedToNumber = Val(strValue)
End If
End Function