by Jim Fouch (4 Submissions)
Category: Math/Dates
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Mon 10th September 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Function to convert COBOL formated numbers into VB
Optional Dec As Byte = 2, _
Optional ConversionTable As String = "{ABCDEFGHI}JKLMNOPQR", _
Optional ConversionValues As String = "01234567890123456789") As Currency
' ================================================================================
'
' Created: Wed Feb-28-2001 @ 10:20 AM By: jfouch
' Revised: Wed Feb-28-2001 @ 10:20 AM By: jfouch
'
' Desc: This function will convert Cobol dollars into VB Currency Values
' ================================================================================
Dim p As Byte
Dim v As String * 1
If S = String(Len(S), "0") Then
GetCobolDollars = 0
Exit Function
End If
p = InStr(ConversionTable, Right(S, 1)) ' find Pos of last char in string
If p <> 0 Then
v = Mid(ConversionValues, p, 1) ' find the value for the Last Char
Else
v = "0"
End If
GetCobolDollars = CCur((Val(String(Abs(p > 10), "-") & _
Left(S, Len(S) - 1)) & v) / (10 ^ Dec))
End Function