Convert Amount in Words in VB6

Convert Amount in Words in VB6

Public Function AlfaToChar(DllWhichval As Double, Optional RsUsd As String, Optional LengT As String) As String
If LengT = "" Then LengT = "ENGLISH"
If DllWhichval < 0 Then
    If UCase(LengT) = "GUJARATI" Then
        AlfaToChar = ""
    Else
        AlfaToChar = "Invalid input"
    End If
    Exit Function
End If
If At(".", CStr(DllWhichval), 2) <> 0 Then
    If UCase(LengT) = "GUJARATI" Then
        AlfaToChar = ""
    Else
        AlfaToChar = "You have entered some wrong value"
    End If
   Exit Function
End If
If Len(LTrim(RTrim(CStr(DllWhichval)))) > 14 Then
    If UCase(LengT) = "GUJARATI" Then
        AlfaToChar = ""
    Else
        AlfaToChar = "You have entered some wrong value"
    End If
    Exit Function
End If

Dim TempVar1 As Double
Dim TempVar2 As Double
Dim TempVar3 As Double
Dim TankRetu As String

StoreArray LengT
TempVar1 = Int(DllWhichval)
TempVar2 = DllWhichval - Int(DllWhichval)
If At(".", CStr(DllWhichval), 1) = 0 Then
    TempVar2 = 0
Else
    TempVar2 = Mid(CStr(DllWhichval), (At(".", CStr(DllWhichval), 1)), 3)
End If

TempVar3 = 0
TankRetu = ""
If Len(str(TempVar1)) > 7 Then
    TempVar3 = Val(Mid(CStr(TempVar1), 1, Len(CStr(TempVar1)) - 7))
    TempVar1 = Val(Right(CStr(TempVar1), 7))
End If
Dim Var1 As String
Dim Var2 As String
Dim Var3 As String
Var1 = Allt(RetuChr(TempVar1, LengT))
Var2 = Allt(RetuChr(TempVar2 * 100, LengT))
Var3 = Allt(RetuChr(TempVar3, LengT))
If Len(LTrim(RTrim(Var1))) = 0 Then
    If UCase(LengT) = "GUJARATI" Then
       Var1 = "Zero"
    Else
        Var1 = "jIRO"
    End If
End If
If UCase(LengT) = "GUJARATI" Then
    Var3 = IIf(Allt(Var3) <> "", Var3 + " KROD ", "")
Else
    Var3 = IIf(Allt(Var3) <> "", Var3 + " Core ", "")
End If
If TempVar2 = 0 Then
    If UCase(LengT) = "GUJARATI" Then
        Var2 = " PURa."
    Else
        Var2 = " only."
    End If
Else
    If UCase(LengT) = "GUJARATI" Then
        Var2 = " ANE " + IIf(Var2 = "", "", Var2 + " PeSa PURa.")
    Else
        Var2 = " and " + IIf(Var2 = "", "", Var2 + " Paisa Only.")
    End If
End If

If Var3 + Var1 + Var2 = "Zero only." Or Var3 + Var1 + Var2 = "jIRO PURa." Or Var3 + Var1 + Var2 = "jIRO only." Then
    AlfaToChar = ""
Else
    AlfaToChar = Trim(RsUsd + " " + Var3 + Var1 + Var2)
End If

End Function