﻿
Partial Class Default2
    Inherits System.Web.UI.Page
    Structure DATOCE
        <VBFixedString(6)> Public REGISTRO As String
        <VBFixedString(30)> Public APELLIDO As String
        <VBFixedString(30)> Public NOMBRES As String
    End Structure
    Structure RUBR
        <VBFixedString(4)> Public INC As String
        <VBFixedString(6)> Public CODIG As String
        <VBFixedString(50)> Public RUBRO As String
        <VBFixedString(10)> Public ALI1 As String
        <VBFixedString(10)> Public MINI As String
    End Structure
    Structure NEGO
        <VBFixedString(10)> Public NI As String
        <VBFixedString(10)> Public CLAVE As String
        <VBFixedString(50)> Public NO As String
        <VBFixedString(11)> Public NDOC As String
        <VBFixedString(15)> Public CUIT As String
        <VBFixedString(35)> Public UBICA As String
        <VBFixedString(35)> Public DOMPOS As String
        <VBFixedString(35)> Public LOCA As String
        <VBFixedString(15)> Public IBRU As String
        <VBFixedString(15)> Public FEC As String
        <VBFixedString(10)> Public RU1 As String
        <VBFixedString(10)> Public RU2 As String
        <VBFixedString(10)> Public RU3 As String
        <VBFixedString(10)> Public RU4 As String
        <VBFixedString(10)> Public RU5 As String
        <VBFixedString(10)> Public RU6 As String
        <VBFixedString(10)> Public RU7 As String
    End Structure
    Structure VENC1
        <VBFixedString(5)> Public ANO As String
        <VBFixedString(9)> Public FE1 As String
        <VBFixedString(9)> Public FE2 As String
        <VBFixedString(9)> Public FE3 As String
        <VBFixedString(9)> Public FE4 As String
        <VBFixedString(9)> Public FE5 As String
        <VBFixedString(9)> Public FE6 As String
        <VBFixedString(9)> Public FE7 As String
        <VBFixedString(9)> Public FE8 As String
        <VBFixedString(9)> Public FE9 As String
        <VBFixedString(9)> Public FE10 As String
        <VBFixedString(9)> Public FE11 As String
        <VBFixedString(9)> Public FE12 As String
    End Structure
    Structure MORAPA
        <VBFixedString(10)> Public MORA As String
        <VBFixedString(10)> Public MULTA As String
        <VBFixedString(10)> Public FONDO As String
    End Structure
    Structure CREDIX
        <VBFixedString(13)> Public F As String
        <VBFixedString(5)> Public R As String
        <VBFixedString(5)> Public N As String
        <VBFixedString(3)> Public PX As String
        <VBFixedString(5)> Public ANO As String
        <VBFixedString(15)> Public C As String
        <VBFixedString(10)> Public i As String
        <VBFixedString(10)> Public FDO As String
        <VBFixedString(10)> Public MOR As String
        <VBFixedString(10)> Public MULTA As String
        <VBFixedString(10)> Public DESCU As String
        <VBFixedString(4)> Public PL As String
        <VBFixedString(2)> Public LUG As String
        <VBFixedString(10)> Public PLAN As String
        <VBFixedString(10)> Public ORDE As String
        <VBFixedString(10)> Public ACTIV As String
        <VBFixedString(10)> Public CLAVE As String
    End Structure
    Dim I As Integer
    Dim J As Integer
    Dim F As Integer
    Dim DataToPrint As String
    Dim OnlyCorrectData As String
    Dim PrintableString As String
    Dim Encoding As String
    Dim WeightedTotal As Long
    Dim WeightValue As Integer
    Dim CurrentValue As Long
    Dim CheckDigitValue As Integer
    Dim Factor As Integer
    Dim CheckDigit As Integer
    Dim CurrentEncoding As String
    Dim NewLine As String
    Dim msg As String
    Dim CurrentChar As String
    Dim CurrentCharNum As Integer
    Dim C128_StartA As String
    Dim C128_StartB As String
    Dim C128_StartC As String
    Dim C128_Stop As String
    Dim C128Start As String
    Dim C128CheckDigit As String
    Dim StartCode As String
    Dim StopCode As String
    Dim Fnc1 As String
    Dim LeadingDigit As Integer
    Dim EAN2AddOn As String
    Dim EAN5AddOn As String
    Dim EANAddOnToPrint As String
    Dim HumanReadableText As String
    Dim StringLength As Integer
    Dim CorrectFNC As Integer
    Dim CID As Integer
    Dim FID As Integer
    Dim NCID As Integer
    'Arrays
    Dim SetAry(100) As String
    Dim ProcessTilde(100) As String
    Dim EAN13(100) As String
    'END OF DECLARACTIONS



    Public Function Code128a(ByVal DataToEncode As String, Optional ByVal ReturnType As Integer = 0) As String
        'This method has been updated to support ReturnTypes 6 to 9,
        'which increases its complexity. IDAutomation suggests using
        'the prior version (http://www.idautomation.com/fonts/tools/barcodeapp/module1.txt)
        'of this code when performing conversions or modifications.
        'ReturnTypes are explained at http://www.idautomation.com/barcode/return-type.html
        '
        'The next 7 lines were added to support ReturnTypes 6-9
        CID = 0 'Character ID
        FID = 0 'Function ID used for start, stop and check characters
        If ReturnType = 6 Or ReturnType = 7 Then CID = 11000
        If ReturnType = 8 Then CID = 11300
        If ReturnType = 9 Then CID = 11500
        If ReturnType = 6 Or ReturnType = 9 Then FID = 11500
        If ReturnType = 7 Or ReturnType = 8 Then FID = 11300
        PrintableString = ""
        WeightedTotal = 103
        PrintableString = ChrW(203 + FID)
        StringLength = Len(DataToEncode)
        For I = 1 To StringLength
            CurrentCharNum = AscW(Mid(DataToEncode, I, 1))
            If CurrentCharNum < 135 Then CurrentValue = CurrentCharNum - 32
            If CurrentCharNum > 134 Then CurrentValue = CurrentCharNum - 100
            CurrentValue = CurrentValue * I
            WeightedTotal = WeightedTotal + CurrentValue
            If CurrentCharNum = 32 Then CurrentCharNum = 194
            'The next 6 lines include updates to support ReturnTypes 6 and 7
            'This update keeps control characters out of HR text.
            If (ReturnType = 6 Or ReturnType = 7) And (CurrentCharNum > 95) Then
                PrintableString = PrintableString & ChrW(CurrentCharNum + 11500)
            Else
                PrintableString = PrintableString & ChrW(CurrentCharNum + CID)
            End If
        Next I
        CheckDigitValue = (WeightedTotal Mod 103)
        If CheckDigitValue < 95 And CheckDigitValue > 0 Then C128CheckDigit = ChrW(CheckDigitValue + 32 + FID)
        If CheckDigitValue > 94 Then C128CheckDigit = ChrW(CheckDigitValue + 100 + FID)
        If CheckDigitValue = 0 Then C128CheckDigit = ChrW(194 + FID)
        PrintableString = PrintableString & C128CheckDigit & ChrW(206 + FID)
        Code128a = PrintableString
    End Function


    Public Function Code128b(ByVal DataToEncode As String, Optional ByVal ReturnType As Integer = 0) As String
        'This method has been updated to support ReturnTypes 6 to 9,
        'which increases its complexity. IDAutomation suggests using
        'the prior version (http://www.idautomation.com/fonts/tools/barcodeapp/module1.txt)
        'of this code when performing conversions or modifications.
        'ReturnTypes are explained at http://www.idautomation.com/barcode/return-type.html
        '
        PrintableString = ""
        WeightedTotal = 104
        'The next 9 lines were added to support ReturnTypes 6-9
        'in addition, CSID must be added to all ChrW statements
        'Return types: 6=HR mode; 7=HR tall FID; 8=comp mode no HR; 9=comp mode no hr short
        CID = 0 'Character ID
        FID = 0 'Function ID used for start, stop and check characters
        If ReturnType = 6 Or ReturnType = 7 Then CID = 11000
        If ReturnType = 8 Then CID = 11300
        If ReturnType = 9 Then CID = 11500
        If ReturnType = 6 Or ReturnType = 9 Then FID = 11500
        If ReturnType = 7 Or ReturnType = 8 Then FID = 11300
        PrintableString = ChrW(204 + FID)
        StringLength = Len(DataToEncode)
        For I = 1 To StringLength
            CurrentCharNum = AscW(Mid(DataToEncode, I, 1))
            If CurrentCharNum < 135 Then CurrentValue = CurrentCharNum - 32
            If CurrentCharNum > 134 Then CurrentValue = CurrentCharNum - 100
            CurrentValue = CurrentValue * I
            WeightedTotal = WeightedTotal + CurrentValue
            If CurrentCharNum = 32 Then CurrentCharNum = 194
            PrintableString = PrintableString & ChrW(CurrentCharNum + CID)
        Next I
        CheckDigitValue = (WeightedTotal Mod 103)
        If CheckDigitValue < 95 And CheckDigitValue > 0 Then C128CheckDigit = ChrW(CheckDigitValue + 32 + FID)
        If CheckDigitValue > 94 Then C128CheckDigit = ChrW(CheckDigitValue + 100 + FID)
        If CheckDigitValue = 0 Then C128CheckDigit = ChrW(194 + FID)
        PrintableString = PrintableString & C128CheckDigit & ChrW(206 + FID)
        Code128b = PrintableString
    End Function




    Public Function I2of5(ByVal DataToEncode As String) As String
        DataToPrint = ""
        DataToEncode = RTrim(LTrim(DataToEncode))
        OnlyCorrectData = ""
        ' Check to make sure data is numeric and remove dashes, etc.
        StringLength = Len(DataToEncode)
        For I = 1 To StringLength
            'Add all numbers to OnlyCorrectData string
            '2006.2 BDA modified the next 3 lines for compatibility with different office versions
            'If IsNumeric(Mid(DataToEncode, I, 1)) Then OnlyCorrectData = OnlyCorrectData & Mid(DataToEncode, I, 1)
            CurrentCharNum = AscW(Mid(DataToEncode, I, 1))
            If CurrentCharNum > 47 And CurrentCharNum < 58 Then OnlyCorrectData = OnlyCorrectData & Mid(DataToEncode, I, 1)
        Next I
        DataToEncode = OnlyCorrectData
        'Check for an even number of digits, add 0 if not even
        If (Len(DataToEncode) Mod 2) = 1 Then DataToEncode = "0" & DataToEncode
        'Assign start and stop codes
        StartCode = ChrW(203)
        StopCode = ChrW(204)
        StringLength = Len(DataToEncode)
        For I = 1 To StringLength Step 2
            'Get the value of each number pair
            CurrentCharNum = Val((Mid(DataToEncode, I, 2)))
            'Get the ASCII value of CurrentChar
            If CurrentCharNum < 94 Then DataToPrint = DataToPrint & ChrW(CurrentCharNum + 33)
            If CurrentCharNum > 93 Then DataToPrint = DataToPrint & ChrW(CurrentCharNum + 103)
        Next I
        'Get Printable String
        PrintableString = StartCode + DataToPrint + StopCode
        'Return PrintableString
        I2of5 = PrintableString
    End Function




    Public Function Code39(ByVal DataToEncode As String) As String
        DataToEncode = RTrim(LTrim(DataToEncode))
        DataToPrint = ""
        'Check for spaces in code
        StringLength = Len(DataToEncode)
        For I = 1 To StringLength
            'Get each character one at a time
            CurrentChar = (Mid(DataToEncode, I, 1))
            'To print the barcode symbol representing a space it is necessary
            'to type or print "=" (the equal character) instead of a space character.
            If CurrentChar = " " Then CurrentChar = "="
            DataToPrint = DataToPrint & CurrentChar
        Next I
        'Get Printable String
        Code39 = "!" & DataToPrint & "!"
        DataToEncode = ""
    End Function


    Public Function MSI(ByVal DataToEncode As String, Optional ByVal ReturnType As Integer = 0) As String
        'Additional logic needed in case ReturnType is not entered correctly
        If ReturnType <> 0 And ReturnType <> 1 And ReturnType <> 2 Then ReturnType = 0
        'The MSI encoding function will only accept digits. Any non-numeric characters
        'will be discarded
        Dim DataToPrint As String       'output for function
        Dim OnlyCorrectData As String   'Only numeric characters pulled from DataToEncode
        Dim StringLength As Long        'Length of string
        Dim Idx As Integer              'for loop counter
        Dim OddNumbers As String        'String of odd position numbers used to create check digit
        Dim EvenNumberSum As Long       'all of the even position numbers added up
        Dim OddNumberProduct As Long    'Product of OddNumbers variable
        Dim sOddNumberProduct As String 'String version of OddNumberProduct variable
        Dim OddNumberSum As Long        'Sum of individual digits in sOddNumberProduct
        Dim OddDigit As Boolean         'Used to determine even/odd position digits.
        Dim CheckDigit As String        'This is the CheckDigit
        DataToPrint = ""
        OnlyCorrectData = ""
        'Check to make sure data is numeric
        StringLength = Len(DataToEncode)
        For I = 1 To StringLength
            'Add all numbers to OnlyCorrectData string
            '2006.2 BDA modified the next 3 lines for compatibility with different office versions
            'If IsNumeric(Mid(DataToEncode, I, 1)) Then OnlyCorrectData = OnlyCorrectData & Mid(DataToEncode, I, 1)
            CurrentCharNum = AscW(Mid(DataToEncode, I, 1))
            If CurrentCharNum > 47 And CurrentCharNum < 58 Then OnlyCorrectData = OnlyCorrectData & Mid(DataToEncode, I, 1)
        Next I
        DataToEncode = OnlyCorrectData
        '<<<< Calculate Check Digit >>>>
        'To create the check digit follow these steps:
        '1)Starting from the units position, create a new number with all of the odd
        '  position digits in their original sequence.
        '2)Multiply this new number by 2.
        '3)Add all of the digits of the product from step two.
        '4)Add all of the digits not used in step one to the result in step three.
        '5)Determine the smallest number which when added to the result in step four
        '  will result in a multiple of 10. This is the check character.
        'Step 1 -- Create a new number of the odd position digits starting from the right and going left, but store the
        'digits from left to right.
        'Create the odd position number & prepare for Step 4 by getting the sum of all even position characters
        StringLength = Len(DataToEncode)
        OddNumbers = ""
        OddDigit = True
        EvenNumberSum = 0
        For Idx = StringLength To 1 Step -1
            If OddDigit = True Then
                OddNumbers = Mid(DataToEncode, Idx, 1) & OddNumbers
                OddDigit = False
            Else
                EvenNumberSum = EvenNumberSum + Val(Mid(DataToEncode, Idx, 1))
                OddDigit = True
            End If
        Next Idx
        'Step 2 -- Multiply this new number by 2.
        OddNumberProduct = Val(OddNumbers) * 2
        'Step 3 -- Add all of the digits of the product from step two.
        sOddNumberProduct = Format(OddNumberProduct)
        StringLength = Len(sOddNumberProduct)
        OddNumberSum = 0
        For Idx = 1 To StringLength
            OddNumberSum = OddNumberSum + Val(Mid(sOddNumberProduct, Idx, 1))
        Next Idx
        'Step 4 -- Add all of the digits not used in step one to the result in step three.
        'We will store the result in OddNumberSum just so we don't have to create another variable
        OddNumberSum = OddNumberSum + EvenNumberSum
        'Step 5 -- Determine the smallest number which when added to the result in step four
        'will result in a multiple of 10. This is the check character.
        OddNumberSum = OddNumberSum Mod 10
        If OddNumberSum <> 0 Then
            CheckDigit = Format(10 - OddNumberSum)
        Else
            CheckDigit = "0"
        End If
        Select Case ReturnType
            Case 0  'Returns formatted data for barcode
                DataToPrint = "(" & DataToEncode & CheckDigit & ")"
            Case 1  'Returns data formatted for human readable text.
                'Which means all of the invalid characters are
                'stripped out.
                DataToPrint = DataToEncode
            Case 2  'Returns just the check digit
                DataToPrint = CheckDigit
        End Select
        MSI = DataToPrint
    End Function




    Public Function IDAEAN13(ByVal DataToEncode As String) As String
        'This function was added for compatibility with Excel 2007 which refers to EAN13 as a cell location
        IDAEAN13 = EAN13(DataToEncode)
    End Function


    Public Function Code11(ByVal DataToEncode As String) As String
        DataToPrint = ""
        OnlyCorrectData = ""
        ' Check to make sure data is numeric and remove dashes, etc.
        StringLength = Len(DataToEncode)
        For I = 1 To StringLength
            'Add all numbers to OnlyCorrectData string
            '2006.2 BDA modified the next 2 lines for compatibility with different office versions
            CurrentCharNum = AscW(Mid(DataToEncode, I, 1))
            If (CurrentCharNum > 47 And CurrentCharNum < 58) Or CurrentCharNum = 45 Then OnlyCorrectData = OnlyCorrectData & Mid(DataToEncode, I, 1)
        Next I
        DataToEncode = OnlyCorrectData
        'Calculate Check Digit
        Factor = 1
        WeightedTotal = 0
        For I = Len(DataToEncode) To 1 Step -1
            'Get the value of each number starting at the end
            CurrentChar = Mid(DataToEncode, I, 1)
            'Set the "-" character to the value of 10
            If CurrentChar = "-" Then CurrentChar = "10"
            'Multiply by the weighting character and add together
            WeightedTotal = WeightedTotal + Val(CurrentChar) * Factor
            'Change factor for next calculation
            Factor = Factor + 1
        Next I
        'Find the Modulo 11 check digit
        CheckDigit = WeightedTotal Mod 11
        Code11 = "(" & DataToEncode & CheckDigit & ")"
    End Function


    Public Function RM4SCC(ByVal DataToEncode As String) As String
        DataToEncode = UCase(DataToEncode)
        OnlyCorrectData = ""
        StringLength = Len(DataToEncode)
        For I = 1 To StringLength
            'Get each character one at a time
            CurrentCharNum = AscW(Mid(DataToEncode, I, 1))
            'Get the value of CurrentChar according to MOD43
            '0-9
            If CurrentCharNum < 58 And CurrentCharNum > 47 Then OnlyCorrectData = OnlyCorrectData & Mid(DataToEncode, I, 1)
            'A-Z
            If CurrentCharNum < 91 And CurrentCharNum > 64 Then OnlyCorrectData = OnlyCorrectData & Mid(DataToEncode, I, 1)
        Next I
        DataToEncode = OnlyCorrectData
        Dim r As Integer
        Dim C As Integer
        Dim Rtotal As Long
        Dim Ctotal As Long
        Rtotal = 0
        Ctotal = 0
        WeightedTotal = 0
        StringLength = Len(DataToEncode)
        For I = 1 To StringLength
            'Get each character one at a time
            CurrentChar = Mid(DataToEncode, I, 1)
            'Get the values of CurrentChar
            Select Case CurrentChar
                Case "0"
                    r = 1
                    C = 1
                Case "1"
                    r = 1
                    C = 2
                Case "2"
                    r = 1
                    C = 3
                Case "3"
                    r = 1
                    C = 4
                Case "4"
                    r = 1
                    C = 5
                Case "5"
                    r = 1
                    C = 0
                Case "6"
                    r = 2
                    C = 1
                Case "7"
                    r = 2
                    C = 2
                Case "8"
                    r = 2
                    C = 3
                Case "9"
                    r = 2
                    C = 4
                Case "A"
                    r = 2
                    C = 5
                Case "B"
                    r = 2
                    C = 0
                Case "C"
                    r = 3
                    C = 1
                Case "D"
                    r = 3
                    C = 2
                Case "E"
                    r = 3
                    C = 3
                Case "F"
                    r = 3
                    C = 4
                Case "G"
                    r = 3
                    C = 5
                Case "H"
                    r = 3
                    C = 0
                Case "I"
                    r = 4
                    C = 1
                Case "J"
                    r = 4
                    C = 2
                Case "K"
                    r = 4
                    C = 3
                Case "L"
                    r = 4
                    C = 4
                Case "M"
                    r = 4
                    C = 5
                Case "N"
                    r = 4
                    C = 0
                Case "O"
                    r = 5
                    C = 1
                Case "P"
                    r = 5
                    C = 2
                Case "Q"
                    r = 5
                    C = 3
                Case "R"
                    r = 5
                    C = 4
                Case "S"
                    r = 5
                    C = 5
                Case "T"
                    r = 5
                    C = 0
                Case "U"
                    r = 0
                    C = 1
                Case "V"
                    r = 0
                    C = 2
                Case "W"
                    r = 0
                    C = 3
                Case "X"
                    r = 0
                    C = 4
                Case "Y"
                    r = 0
                    C = 5
                Case "Z"
                    r = 0
                    C = 0

            End Select
            'add the values together
            Rtotal = Rtotal + r
            Ctotal = Ctotal + C
        Next I

        'divide the Totals by 6 and get the remainder, this is a reference
        'to the Check Digit.
        'set check digit to CurrentChar (a string)
        Rtotal = (Rtotal Mod 6)
        Ctotal = (Ctotal Mod 6)
        Select Case Rtotal
            Case 1
                Select Case Ctotal
                    Case 1
                        CurrentChar = "0"
                    Case 2
                        CurrentChar = "1"
                    Case 3
                        CurrentChar = "2"
                    Case 4
                        CurrentChar = "3"
                    Case 5
                        CurrentChar = "4"
                    Case 0
                        CurrentChar = "5"
                End Select
            Case 2
                Select Case Ctotal
                    Case 1
                        CurrentChar = "6"
                    Case 2
                        CurrentChar = "7"
                    Case 3
                        CurrentChar = "8"
                    Case 4
                        CurrentChar = "9"
                    Case 5
                        CurrentChar = "A"
                    Case 0
                        CurrentChar = "B"
                End Select
            Case 3
                Select Case Ctotal
                    Case 1
                        CurrentChar = "C"
                    Case 2
                        CurrentChar = "D"
                    Case 3
                        CurrentChar = "E"
                    Case 4
                        CurrentChar = "F"
                    Case 5
                        CurrentChar = "G"
                    Case 0
                        CurrentChar = "H"
                End Select
            Case 4
                Select Case Ctotal
                    Case 1
                        CurrentChar = "I"
                    Case 2
                        CurrentChar = "J"
                    Case 3
                        CurrentChar = "K"
                    Case 4
                        CurrentChar = "L"
                    Case 5
                        CurrentChar = "M"
                    Case 0
                        CurrentChar = "N"
                End Select
            Case 5
                Select Case Ctotal
                    Case 1
                        CurrentChar = "O"
                    Case 2
                        CurrentChar = "P"
                    Case 3
                        CurrentChar = "Q"
                    Case 4
                        CurrentChar = "R"
                    Case 5
                        CurrentChar = "S"
                    Case 0
                        CurrentChar = "T"
                End Select
            Case 0
                Select Case Ctotal
                    Case 1
                        CurrentChar = "U"
                    Case 2
                        CurrentChar = "V"
                    Case 3
                        CurrentChar = "W"
                    Case 4
                        CurrentChar = "X"
                    Case 5
                        CurrentChar = "Y"
                    Case 0
                        CurrentChar = "Z"
                End Select
        End Select
        'Return Printable String
        RM4SCC = "(" & DataToEncode & CurrentChar & ")"
    End Function


    Public Function Codabar(ByVal DataToEncode As String) As String
        DataToPrint = ""
        OnlyCorrectData = ""
        StringLength = Len(DataToEncode)
        'Check to make sure data is numeric, $, +, -, /, or :, and remove all others.
        For I = 1 To StringLength
            '2006.2 BDA modified the next 9 lines for compatibility with different office versions
            CurrentChar = Mid(DataToEncode, I, 1)
            CurrentCharNum = AscW(CurrentChar)
            If CurrentCharNum > 47 And CurrentCharNum < 58 Then OnlyCorrectData = OnlyCorrectData & Mid(DataToEncode, I, 1)
            If CurrentChar = "$" Then OnlyCorrectData = OnlyCorrectData & Mid(DataToEncode, I, 1)
            If CurrentChar = "+" Then OnlyCorrectData = OnlyCorrectData & Mid(DataToEncode, I, 1)
            If CurrentChar = "-" Then OnlyCorrectData = OnlyCorrectData & Mid(DataToEncode, I, 1)
            If CurrentChar = "/" Then OnlyCorrectData = OnlyCorrectData & Mid(DataToEncode, I, 1)
            If CurrentChar = "." Then OnlyCorrectData = OnlyCorrectData & Mid(DataToEncode, I, 1)
            If CurrentChar = ":" Then OnlyCorrectData = OnlyCorrectData & Mid(DataToEncode, I, 1)
        Next I
        DataToPrint = OnlyCorrectData
        'Get Printable String
        Codabar = "A" & DataToPrint & "B"
    End Function




    Public Function Code93(ByVal DataToEncode As String) As String
        DataToEncode = UCase(DataToEncode)
        DataToPrint = ""
        OnlyCorrectData = ""
        'Only pass correct data
        StringLength = Len(DataToEncode)
        For I = 1 To StringLength
            CurrentCharNum = AscW(Mid(DataToEncode, I, 1))
            If Code93Val(CurrentCharNum) < 47 Then
                If CurrentCharNum = 32 Then CurrentCharNum = 61
                OnlyCorrectData = OnlyCorrectData & ChrW(CurrentCharNum)
            End If
        Next I
        DataToEncode = OnlyCorrectData
        CurrentCharNum = 0
        StringLength = Len(DataToEncode)
        Dim C As Integer
        Dim K As Integer
        Dim CW As Integer
        Dim KW As Integer
        Dim CWSum As Integer
        Dim KWSum As Integer
        CW = 1
        KW = 2
        I = 1
        '2006.2 BDA modified the next line for compatibility with different office versions
        For I = StringLength To 1 Step -1
            'Get each character one at a time from the back
            CurrentCharNum = AscW(Mid(DataToEncode, I, 1))
            'Get the value
            CurrentValue = Code93Val(CurrentCharNum)
            'Calculate check digit C
            CWSum = CWSum + (CurrentValue * CW)
            CW = CW + 1
            If CW = 21 Then CW = 1
            'Calculate check digit K
            KWSum = KWSum + (CurrentValue * KW)
            KW = KW + 1
            If KW = 16 Then KW = 1
            'Gather data to print
            DataToPrint = ChrW(CurrentCharNum) & DataToPrint
        Next I
        'Divide the C sum by 47 and get the remainder, this is the Check Digit
        C = (CWSum Mod 47)
        'Add the last digit to the K sum
        KWSum = KWSum + C
        'Divide the K sum by 47 and get the remainder, this is the Check Digit
        K = (KWSum Mod 47)
        Code93 = "(" & DataToPrint & Code93Char(C) & Code93Char(K) & ")"
    End Function

    Private Function Code93Char(ByVal CharValue As Integer) As String
        'Returns a character from a character value
        'An invalid character value returns nothing
        Code93Char = ""
        If CharValue < 10 And CharValue > -1 Then Code93Char = ChrW(CharValue + 48)
        'A-Z
        If CharValue < 36 And CharValue > 9 Then Code93Char = ChrW(CharValue + 55)
        '-
        If CharValue = 36 Then Code93Char = ChrW(45)
        '.
        If CharValue = 37 Then Code93Char = "."
        'Space
        If CharValue = 38 Then Code93Char = "="
        '$
        If CharValue = 39 Then Code93Char = "$"
        '/
        If CharValue = 40 Then Code93Char = "/"
        '+
        If CharValue = 41 Then Code93Char = "+"
        '%
        If CharValue = 42 Then Code93Char = "%"
        '!
        If CharValue = 43 Then Code93Char = "!"
        '#
        If CharValue = 44 Then Code93Char = "#"
        '&
        If CharValue = 45 Then Code93Char = "&"
        '@
        If CharValue = 46 Then Code93Char = "@"
    End Function

    Private Function Code93Val(ByVal CharASCValue As Integer) As Integer
        'Returns a character value from a character
        'An invalid character value returns 99
        Code93Val = 99
        '0-9
        If CharASCValue < 58 And CharASCValue > 47 Then Code93Val = CharASCValue - 48
        'A-Z
        If CharASCValue < 91 And CharASCValue > 64 Then Code93Val = CharASCValue - 55
        'Space
        If CharASCValue = 32 Then Code93Val = 38
        '=
        If CharASCValue = 61 Then Code93Val = 38
        '-
        If CharASCValue = 45 Then Code93Val = 36
        '.
        If CharASCValue = 46 Then Code93Val = 37
        '$
        If CharASCValue = 36 Then Code93Val = 39
        '/
        If CharASCValue = 47 Then Code93Val = 40
        '+
        If CharASCValue = 43 Then Code93Val = 41
        '%
        If CharASCValue = 37 Then Code93Val = 42
        '!
        If CharASCValue = 33 Then Code93Val = 43
        '#
        If CharASCValue = 35 Then Code93Val = 44
        '&
        If CharASCValue = 38 Then Code93Val = 45
        '@
        If CharASCValue = 64 Then Code93Val = 46
    End Function


    Public Function SpliceText(ByVal DataToFormat As String, Optional ByVal SpacingNumber As Integer = 4, Optional ByVal ApplyTilde As Boolean = False) As String
        'This function inserts a space for every SpacingNumber of characters
        '2006.2 BDA added the next line to move code to the ProcessTilde function
        If ApplyTilde Then DataToFormat = ProcessTilde(DataToFormat)
        HumanReadableText = ""
        StringLength = Len(DataToFormat)
        J = 0
        For I = 1 To StringLength
            CurrentCharNum = AscW(Mid(DataToFormat, I, 1))
            If CurrentCharNum > 31 And CurrentCharNum < 128 Then
                HumanReadableText = HumanReadableText & Mid(DataToFormat, I, 1)
                J = J + 1
            End If
            If (J Mod SpacingNumber) = 0 Then HumanReadableText = HumanReadableText & " "
        Next I
        SpliceText = HumanReadableText
    End Function


    Public Function MOD10(ByVal M10NumberData As String) As Integer
        '***********************************************************************
        ' This is a general MOD10 function compatible with EAN and UPC standards
        '***********************************************************************
        Dim M10StringLength As Integer
        Dim M10OnlyCorrectData As String
        Dim M10Factor As Integer
        Dim M10WeightedTotal As Integer
        Dim M10CheckDigit As Integer
        Dim M10I As Integer
        M10OnlyCorrectData = ""
        M10StringLength = Len(M10NumberData)
        'Check to make sure data is numeric and remove dashes, etc.
        For M10I = 1 To M10StringLength
            'Add all numbers to OnlyCorrectData string
            '2006.2 BDA modified the next 2 lines for compatibility with different office versions
            CurrentCharNum = AscW(Mid(M10NumberData, M10I, 1))
            If CurrentCharNum > 47 And CurrentCharNum < 58 Then M10OnlyCorrectData = M10OnlyCorrectData & Mid(M10NumberData, M10I, 1)
        Next M10I
        'Generate MOD 10 check digit
        M10Factor = 3
        M10WeightedTotal = 0
        M10StringLength = Len(M10NumberData)
        For M10I = M10StringLength To 1 Step -1
            'Get the value of each number starting at the end
            'CurrentCharNum = Mid(M10NumberData, I, 1)
            'Multiply by the weighting factor which is 3,1,3,1...
            'and add the sum together
            M10WeightedTotal = M10WeightedTotal + (Val(Mid(M10NumberData, M10I, 1)) * M10Factor)
            'Change factor for next calculation
            M10Factor = 4 - M10Factor
        Next M10I
        'Find the CheckDigit by finding the smallest number that = a multiple of 10
        M10I = (M10WeightedTotal Mod 10)
        If M10I <> 0 Then
            M10CheckDigit = (10 - M10I)
        Else
            M10CheckDigit = 0
        End If
        MOD10 = Str(M10CheckDigit)
    End Function




    Public Function ProcessEAN5AddOn(ByVal EAN5AddOn As String) As String
        If Len(EAN5AddOn) = 5 Then
            EANAddOnToPrint = ""
            'Get the check digit for the add on
            Factor = 3
            WeightedTotal = 0
            For I = Len(EAN5AddOn) To 1 Step -1
                'Get the value of each number starting at the end
                CurrentCharNum = Mid(EAN5AddOn, I, 1)
                'Multiply by the weighting factor which is 3,9,3,9.
                'and add the sum together
                If Factor = 3 Then WeightedTotal = WeightedTotal + CurrentCharNum * 3
                If Factor = 1 Then WeightedTotal = WeightedTotal + CurrentCharNum * 9
                'Change factor for next calculation
                Factor = 4 - Factor
            Next I
            'Find the CheckDigit by extracting the right-most number from WeightedTotal
            CheckDigit = Val(Strings.Right(WeightedTotal, 1))
            'Encode the add-on CheckDigit into the number sets
            'by using variable parity between character sets A and B
            Select Case CheckDigit
                Case 0
                    Encoding = "BBAAA"
                Case 1
                    Encoding = "BABAA"
                Case 2
                    Encoding = "BAABA"
                Case 3
                    Encoding = "BAAAB"
                Case 4
                    Encoding = "ABBAA"
                Case 5
                    Encoding = "AABBA"
                Case 6
                    Encoding = "AAABB"
                Case 7
                    Encoding = "ABABA"
                Case 8
                    Encoding = "ABAAB"
                Case 9
                    Encoding = "AABAB"
            End Select
            'Determine the characters to print for proper barcoding
            For I = 1 To Len(EAN5AddOn)
                'Get the value of each number encoded with variable parity
                CurrentChar = Mid(EAN5AddOn, I, 1)
                CurrentEncoding = Mid(Encoding, I, 1)
                'Print different barcodes according to the location of the CurrentChar and CurrentEncoding
                Select Case CurrentEncoding
                    Case "A"
                        If CurrentChar = "0" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(34)
                        If CurrentChar = "1" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(35)
                        If CurrentChar = "2" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(36)
                        If CurrentChar = "3" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(37)
                        If CurrentChar = "4" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(38)
                        If CurrentChar = "5" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(44)
                        If CurrentChar = "6" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(46)
                        If CurrentChar = "7" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(47)
                        If CurrentChar = "8" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(58)
                        If CurrentChar = "9" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(59)
                    Case "B"
                        If CurrentChar = "0" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(122)
                        If CurrentChar = "1" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(61)
                        If CurrentChar = "2" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(63)
                        If CurrentChar = "3" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(64)
                        If CurrentChar = "4" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(91)
                        If CurrentChar = "5" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(92)
                        If CurrentChar = "6" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(93)
                        If CurrentChar = "7" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(95)
                        If CurrentChar = "8" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(123)
                        If CurrentChar = "9" Then EANAddOnToPrint = EANAddOnToPrint & ChrW(125)
                End Select
                'Add in the space & add-on guard pattern
                Select Case I
                    Case 1
                        EANAddOnToPrint = ChrW(43) & EANAddOnToPrint & ChrW(33)
                        'Print add-on delineators between each add-on character
                    Case 2
                        EANAddOnToPrint = EANAddOnToPrint & ChrW(33)
                    Case 3
                        EANAddOnToPrint = EANAddOnToPrint & ChrW(33)
                    Case 4
                        EANAddOnToPrint = EANAddOnToPrint & ChrW(33)
                    Case 5
                        EANAddOnToPrint = EANAddOnToPrint
                End Select
            Next I
        End If
        ProcessEAN5AddOn = EANAddOnToPrint
    End Function
    Public Function ENLETRAS(ByVal NUMERO As String) As String
        Dim b, paso As Integer
        Dim expresion As String
        Dim entero As String
        Dim DECI As String
        Dim flag As String
        flag = "N"
        DECI = ""
        entero = ""
        expresion = ""
        For paso = 1 To Len(NUMERO)
            If Mid(NUMERO, paso, 1) = "." Then
                flag = "S"
            Else
                If flag = "N" Then
                    entero = entero + Mid(NUMERO, paso, 1) 'Extae la parte entera del numero
                Else
                    DECI = DECI + Mid(NUMERO, paso, 1) 'Extrae la parte decimal del numero
                End If
            End If
        Next paso

        If Len(DECI) = 1 Then
            DECI = DECI & "0"
        End If

        flag = "N"
        If Val(NUMERO) >= -999999999 And Val(NUMERO) <= 999999999 Then 'si el numero esta dentro de 0 a 999.999.999
            For paso = Len(entero) To 1 Step -1
                b = Len(entero) - (paso - 1)
                Select Case paso
                    Case 3, 6, 9
                        Select Case Mid(entero, b, 1)
                            Case "1"
                                If Mid(entero, b + 1, 1) = "0" And Mid(entero, b + 2, 1) = "0" Then
                                    expresion = expresion & "CIEN "
                                Else
                                    expresion = expresion & "CIENTO "
                                End If
                                flag = "N"
                            Case "2"
                                expresion = expresion & "DOSCIENTOS "
                                flag = "N"
                            Case "3"
                                expresion = expresion & "TRESCIENTOS "
                                flag = "N"
                            Case "4"
                                expresion = expresion & "CUATROCIENTOS "
                                flag = "N"
                            Case "5"
                                expresion = expresion & "QUINIENTOS "
                                flag = "N"
                            Case "6"
                                expresion = expresion & "SEISCIENTOS "
                                flag = "N"
                            Case "7"
                                expresion = expresion & "SETECIENTOS "
                                flag = "N"
                            Case "8"
                                expresion = expresion & "OCHOCIENTOS "
                                flag = "N"
                            Case "9"
                                expresion = expresion & "NOVECIENTOS "
                                flag = "N"
                        End Select

                    Case 2, 5, 8
                        Select Case Mid(entero, b, 1)
                            Case "1"
                                If Mid(entero, b + 1, 1) = "0" Then
                                    flag = "S"
                                    expresion = expresion & "DIEZ "
                                End If
                                If Mid(entero, b + 1, 1) = "1" Then
                                    flag = "S"
                                    expresion = expresion & "ONCE "
                                End If
                                If Mid(entero, b + 1, 1) = "2" Then
                                    flag = "S"
                                    expresion = expresion & "DOCE "
                                End If
                                If Mid(entero, b + 1, 1) = "3" Then
                                    flag = "S"
                                    expresion = expresion & "TRECE "
                                End If
                                If Mid(entero, b + 1, 1) = "4" Then
                                    flag = "S"
                                    expresion = expresion & "CATORCE "
                                End If
                                If Mid(entero, b + 1, 1) = "5" Then
                                    flag = "S"
                                    expresion = expresion & "QUINCE "
                                End If
                                If Mid(entero, b + 1, 1) > "5" Then
                                    flag = "N"
                                    expresion = expresion & "DIECI"
                                End If

                            Case "2"
                                If Mid(entero, b + 1, 1) = "0" Then
                                    expresion = expresion & "VEINTE "
                                    flag = "S"
                                Else
                                    expresion = expresion & "VEINTI"
                                    flag = "N"
                                End If

                            Case "3"
                                If Mid(entero, b + 1, 1) = "0" Then
                                    expresion = expresion & "TREINTA "
                                    flag = "S"
                                Else
                                    expresion = expresion & "TREINTA y "
                                    flag = "N"
                                End If

                            Case "4"
                                If Mid(entero, b + 1, 1) = "0" Then
                                    expresion = expresion & "CUARENTA "
                                    flag = "S"
                                Else
                                    expresion = expresion & "CUARENTA y "
                                    flag = "N"
                                End If

                            Case "5"
                                If Mid(entero, b + 1, 1) = "0" Then
                                    expresion = expresion & "CINCUENTA "
                                    flag = "S"
                                Else
                                    expresion = expresion & "CINCUENTA y "
                                    flag = "N"
                                End If

                            Case "6"
                                If Mid(entero, b + 1, 1) = "0" Then
                                    expresion = expresion & "SESENTA "
                                    flag = "S"
                                Else
                                    expresion = expresion & "SESENTA y "
                                    flag = "N"
                                End If

                            Case "7"
                                If Mid(entero, b + 1, 1) = "0" Then
                                    expresion = expresion & "SETENTA "
                                    flag = "S"
                                Else
                                    expresion = expresion & "SETENTA y "
                                    flag = "N"
                                End If

                            Case "8"
                                If Mid(entero, b + 1, 1) = "0" Then
                                    expresion = expresion & "OCHENTA "
                                    flag = "S"
                                Else
                                    expresion = expresion & "OCHENTA y "
                                    flag = "N"
                                End If

                            Case "9"
                                If Mid(entero, b + 1, 1) = "0" Then
                                    expresion = expresion & "NOVENTA "
                                    flag = "S"
                                Else
                                    expresion = expresion & "NOVENTA y "
                                    flag = "N"
                                End If
                        End Select

                    Case 1, 4, 7
                        Select Case Mid(entero, b, 1)
                            Case "1"
                                If flag = "N" Then
                                    If paso = 1 Then
                                        expresion = expresion & "UNO "
                                    Else
                                        expresion = expresion & "UN "
                                    End If
                                End If
                            Case "2"
                                If flag = "N" Then
                                    expresion = expresion & "DOS "
                                End If
                            Case "3"
                                If flag = "N" Then
                                    expresion = expresion & "TRES "
                                End If
                            Case "4"
                                If flag = "N" Then
                                    expresion = expresion & "CUATRO "
                                End If
                            Case "5"
                                If flag = "N" Then
                                    expresion = expresion & "CINCO "
                                End If
                            Case "6"
                                If flag = "N" Then
                                    expresion = expresion & "SEIS "
                                End If
                            Case "7"
                                If flag = "N" Then
                                    expresion = expresion & "SIETE "
                                End If
                            Case "8"
                                If flag = "N" Then
                                    expresion = expresion & "OCHO "
                                End If
                            Case "9"
                                If flag = "N" Then
                                    expresion = expresion & "NUEVE "
                                End If
                        End Select
                End Select
                If paso = 4 Then
                    If Mid(entero, 6, 1) <> "0" Or Mid(entero, 5, 1) <> "0" Or Mid(entero, 4, 1) <> "0" Or _
                      (Mid(entero, 6, 1) = "0" And Mid(entero, 5, 1) = "0" And Mid(entero, 4, 1) = "0" And _
                       Len(entero) <= 6) Then
                        expresion = expresion & "MIL "
                    End If
                End If
                If paso = 7 Then
                    If Len(entero) = 7 And Mid(entero, 1, 1) = "1" Then
                        expresion = expresion & "MILLON "
                    Else
                        expresion = expresion & "MILLONES "
                    End If
                End If
            Next paso

            If DECI <> "" Then
                If Mid(entero, 1, 1) = "-" Then 'si el numero es negativo
                    ENLETRAS = "menos " & expresion & "con " & DECI & "/100"
                Else
                    ENLETRAS = expresion & "con " & DECI & "/100"
                End If
            Else
                If Mid(entero, 1, 1) = "-" Then 'si el numero es negativo
                    ENLETRAS = "menos " & expresion
                Else
                    ENLETRAS = expresion
                End If
            End If
        Else 'si el numero a convertir esta fuera del rango superior e inferior
            ENLETRAS = ""
        End If
    End Function


    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        If Val(TextBox1.Text) <> 0 Then
            Dim PAT As String
            Dim ORDEN As Integer
            Dim NR As Integer
            Dim RU1 As Integer
            Dim RU2 As Integer
            Dim RU3 As Integer
            Dim RU4 As Integer
            NR = Val(TextBox1.Text)
            PAT = System.AppDomain.CurrentDomain.BaseDirectory()
            FileOpen(1, PAT + "ARCHIVOS\NEGOCIOS", OpenMode.Random, OpenAccess.ReadWrite, OpenShare.Shared, 301)
            Dim NEG As New NEGO
            FileGet(1, NEG, 1)
            ORDEN = Val(NEG.CLAVE)
            If ORDEN = 0 Then ORDEN = 1
            FileOpen(2, PAT + "ARCHIVOS\RUBROS", OpenMode.Random, OpenAccess.ReadWrite, OpenShare.Shared, 80)
            Dim RUB As New RUBR
            If NR <= 1 Or NR > ORDEN Then
                MsgBox("REGISTRO FUERA DE RANDO", MsgBoxStyle.Critical)
                TextBox1.Text = ""
                TextBox1.Focus()
                FileClose()
                Exit Sub
            End If
            FileGet(1, NEG, NR)
            REM            TextBox1.Text = DAT.REGISTRO

            TextBox2.Text = NEG.NO
            TextBox4.Text = NEG.CLAVE
            TextBox63.Text = NEG.NI
            TextBox3.Text = NEG.CUIT
            TextBox5.Text = NEG.UBICA
            TextBox6.Text = NEG.DOMPOS
            TextBox7.Text = NEG.LOCA
            RU1 = Val(NEG.RU1)
            If RU1 <> 0 Then
                FileGet(2, RUB, RU1)
                TextBox11.Text = Str$(RU1)
                TextBox12.Text = Trim(RUB.RUBRO)
                TextBox19.Text = Format(Val(RUB.ALI1), "###.00")
                TextBox23.Text = Format(Val(RUB.MINI), "###,###.00")
            End If
            RU2 = Val(NEG.RU2)
            If RU2 <> 0 Then
                FileGet(2, RUB, RU2)
                TextBox13.Text = Str$(RU2)
                TextBox16.Text = Trim(RUB.RUBRO)
                TextBox20.Text = Format(Val(RUB.ALI1), "###.00")
                TextBox24.Text = Format(Val(RUB.MINI), "###,###.00")
            End If
            RU3 = Val(NEG.RU3)
            If RU3 <> 0 Then
                FileGet(2, RUB, RU3)
                TextBox14.Text = Str$(RU3)
                TextBox17.Text = Trim(RUB.RUBRO)
                TextBox22.Text = Format(Val(RUB.ALI1), "###.00")
                TextBox25.Text = Format(Val(RUB.MINI), "###,###.00")
            End If
            RU4 = Val(NEG.RU4)
            If RU4 <> 0 Then
                FileGet(2, RUB, RU4)
                TextBox15.Text = Str$(RU4)
                TextBox18.Text = Trim(RUB.RUBRO)
                TextBox21.Text = Format(Val(RUB.ALI1), "###.00")
                TextBox26.Text = Format(Val(RUB.MINI), "###,###.00")
            End If
            FileClose()
            TextBox8.Focus()
        End If
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim FEC As String
        FEC = Mid$(DateString, 4, 2) + "/" + Mid$(DateString, 1, 2) + "/" + Mid$(DateString, 7, 4)
        TextBox51.Text = FEC
        Dim PAT As String
        PAT = System.AppDomain.CurrentDomain.BaseDirectory()
        FileOpen(1, PAT + "ARCHIVOS\MORAPA", OpenMode.Random, OpenAccess.ReadWrite, OpenShare.Shared, 30)
        Dim MOR As New MORAPA
        FileGet(1, MOR, 1)
        TextBox54.Text = MOR.FONDO
        TextBox52.Text = MOR.MORA
        TextBox53.Text = MOR.MULTA
        FileClose()
        Button1.Attributes.Add("onclick", "history.back(); return false;")
    End Sub

    Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim PAT As String
        PAT = System.AppDomain.CurrentDomain.BaseDirectory()
        Dim NOMBRE As String
        Dim CUIT As String
        Dim UBICA As String
        Dim DOM As String
        Dim LOCA As String
        Dim REG As Integer
        Dim FECHAV As String
        Dim FECHAA As String
        Dim ANO As Integer
        Dim PER As Integer
        Dim ACTIV(10) As String
        Dim IMPONI(10) As Double
        Dim ALICU(10) As Double
        Dim MINI(10) As Double
        Dim TASA(10) As Double
        Dim FONDO(10) As Double
        Dim MORA(10) As Double
        Dim MULTA(10) As Double
        Dim DESCU(10) As Double
        Dim DEBI As String
        Dim DEBITO As String
        Dim LE As Integer
        Dim RESTO As Integer
        Dim NL As String
        Dim DEBI1 As String
        Dim DEBITO1 As String
        Dim LE1 As Integer
        Dim RESTO1 As Integer
        Dim NL1 As String
        Dim DEBI2 As String
        Dim DEBITO2 As String
        Dim LE2 As Integer
        Dim RESTO2 As Integer
        Dim NL2 As String
        Dim ACT1 As String
        Dim ACT2 As String
        Dim ACT3 As String
        Dim ACT4 As String
        Dim DEBI3 As String
        Dim DEBITO3 As String
        Dim LE3 As Integer
        Dim RESTO3 As Integer
        Dim NL3 As String
        Dim DEBI4 As String
        Dim DEBITO4 As String
        Dim LE4 As Integer
        Dim RESTO4 As Integer
        Dim NL4 As String
        Dim DEBI5 As String
        Dim DEBITO5 As String
        Dim LE5 As Integer
        Dim RESTO5 As Integer
        Dim NL5 As String

        Dim RESAC1 As Integer
        Dim RESAC2 As Integer
        Dim RESAC3 As Integer
        Dim RESAC4 As Integer
        Dim TTASA As Double
        Dim TFONDO As Double
        Dim TMORA As Double
        Dim TMULTA As Double
        Dim TDESCU As Double
        Dim TGRAL As Double
        Dim PASO As Integer
        Dim CLAVE As Integer
        Dim PARA As String
        Dim CODIGOX As String
        Dim UG As Integer
        Dim FECC As String
        Dim CODIGOXP As String
        Dim NI As Integer
        Dim TTTASA As Double
        Dim TTFONDO As Double
        Dim TTMORA As Double
        Dim TTMULTA As Double
        Dim TTDESCU As Double
        Dim INSC As Integer


        REM ACTIVIDAD 1
        ACTIV(1) = Format(Val(TextBox11.Text), "000") + "-" + Trim(TextBox12.Text)
        ACTIV(1) = ACTIV(1)
        ACTIV(1) = Strings.Left(ACTIV(1), 30)
        LE1 = Len(ACTIV(1))
        RESAC1 = 30 - LE1
        ACTIV(1) = Trim(ACTIV(1))

        ACT1 = Trim(ACTIV(1))
        ALICU(1) = Val(TextBox19.Text)
        ALICU(1) = Int((ALICU(1) * 100) + 0.5) / 100
        MINI(1) = Val(TextBox23.Text)
        MINI(1) = Int((MINI(1) * 100) + 0.5) / 100
        IMPONI(1) = Val(TextBox27.Text)
        IMPONI(1) = Int((IMPONI(1) * 100) + 0.5) / 100
        TASA(1) = Val(TextBox31.Text)
        TASA(1) = Int((TASA(1) * 100) + 0.5) / 100
        FONDO(1) = Val(TextBox35.Text)
        FONDO(1) = Int((FONDO(1) * 100) + 0.5) / 100
        MORA(1) = Val(TextBox39.Text)
        MORA(1) = Int((MORA(1) * 100) + 0.5) / 100
        MULTA(1) = Val(TextBox43.Text)
        MULTA(1) = Int((MULTA(1) * 100) + 0.5) / 100
        DESCU(1) = Val(TextBox56.Text)
        DESCU(1) = Int((DESCU(1) * 100) + 0.5) / 100
        REM ACTIVIDAD 2
        ACTIV(2) = Format(Val(TextBox13.Text), "000") + "-" + Trim(TextBox16.Text)
        ACTIV(2) = ACTIV(2)
        ACTIV(2) = Strings.Left(ACTIV(2), 30)
        LE1 = Len(ACTIV(2))
        RESAC2 = 30 - LE1
        ACTIV(2) = Trim(ACTIV(2))
        ACT2 = Trim(ACTIV(2))
        ALICU(2) = Val(TextBox20.Text)
        ALICU(2) = Int((ALICU(2) * 100) + 0.5) / 100
        MINI(2) = Val(TextBox24.Text)
        MINI(2) = Int((MINI(2) * 100) + 0.5) / 100
        IMPONI(2) = Val(TextBox28.Text)
        IMPONI(2) = Int((IMPONI(2) * 100) + 0.5) / 100
        TASA(2) = Val(TextBox32.Text)
        TASA(2) = Int((TASA(2) * 100) + 0.5) / 100
        FONDO(2) = Val(TextBox36.Text)
        FONDO(2) = Int((FONDO(2) * 100) + 0.5) / 100
        MORA(2) = Val(TextBox40.Text)
        MORA(2) = Int((MORA(2) * 100) + 0.5) / 100
        MULTA(2) = Val(TextBox44.Text)
        MULTA(2) = Int((MULTA(2) * 100) + 0.5) / 100
        DESCU(2) = Val(TextBox57.Text)
        DESCU(2) = Int((DESCU(2) * 100) + 0.5) / 100

        REM ACTIVIDAD 3
        ACTIV(3) = Format(Val(TextBox14.Text), "000") + "-" + Trim(TextBox17.Text)
        ACTIV(3) = ACTIV(3)
        ACTIV(3) = Strings.Left(ACTIV(3), 30)
        LE1 = Len(ACTIV(3))
        RESAC3 = 30 - LE1
        ACTIV(3) = Trim(ACTIV(3))
        ACT3 = Trim(ACTIV(3))
        ALICU(3) = Val(TextBox22.Text)
        ALICU(3) = Int((ALICU(3) * 100) + 0.5) / 100
        MINI(3) = Val(TextBox25.Text)
        MINI(3) = Int((MINI(3) * 100) + 0.5) / 100
        IMPONI(3) = Val(TextBox29.Text)
        IMPONI(3) = Int((IMPONI(3) * 100) + 0.5) / 100
        TASA(3) = Val(TextBox33.Text)
        TASA(3) = Int((TASA(3) * 100) + 0.5) / 100
        FONDO(3) = Val(TextBox37.Text)
        FONDO(3) = Int((FONDO(3) * 100) + 0.5) / 100
        MORA(3) = Val(TextBox41.Text)
        MORA(3) = Int((MORA(3) * 100) + 0.5) / 100
        MULTA(3) = Val(TextBox45.Text)
        MULTA(3) = Int((MULTA(3) * 100) + 0.5) / 100
        DESCU(3) = Val(TextBox58.Text)
        DESCU(3) = Int((DESCU(3) * 100) + 0.5) / 100

        REM ACTIVIDAD 4
        ACTIV(4) = Format(Val(TextBox14.Text), "000") + "-" + Trim(TextBox17.Text)
        ACTIV(4) = ACTIV(4)
        ACTIV(4) = Strings.Left(ACTIV(4), 30)
        LE1 = Len(ACTIV(4))
        RESAC4 = 30 - LE1
        ACTIV(4) = Trim(ACTIV(4))
        ACT4 = Trim(ACTIV(4))
        ALICU(4) = Val(TextBox22.Text)
        ALICU(4) = Int((ALICU(4) * 100) + 0.5) / 100
        MINI(4) = Val(TextBox25.Text)
        MINI(4) = Int((MINI(4) * 100) + 0.5) / 100
        IMPONI(4) = Val(TextBox29.Text)
        IMPONI(4) = Int((IMPONI(4) * 100) + 0.5) / 100
        TASA(4) = Val(TextBox33.Text)
        TASA(4) = Int((TASA(4) * 100) + 0.5) / 100
        FONDO(4) = Val(TextBox37.Text)
        FONDO(4) = Int((FONDO(4) * 100) + 0.5) / 100
        MORA(4) = Val(TextBox41.Text)
        MORA(4) = Int((MORA(4) * 100) + 0.5) / 100
        MULTA(4) = Val(TextBox45.Text)
        MULTA(4) = Int((MULTA(4) * 100) + 0.5) / 100
        DESCU(4) = Val(TextBox58.Text)
        DESCU(4) = Int((DESCU(4) * 100) + 0.5) / 100


        NOMBRE = Trim(TextBox2.Text)
        CUIT = Trim(TextBox3.Text)
        UBICA = Trim(TextBox5.Text)
        DOM = Trim(TextBox6.Text)
        LOCA = Trim(TextBox7.Text)
        FECHAV = Trim(TextBox10.Text)
        FECHAA = Trim(TextBox51.Text)
        ANO = Val(TextBox8.Text)
        PER = Val(TextBox9.Text)
        REG = Val(TextBox1.Text)
        CLAVE = Val(TextBox4.Text)
        INSC = Val(TextBox63.Text)
        TTTASA = TASA(1) + TASA(2) + TASA(3) + TASA(4)
        TTFONDO = FONDO(1) + FONDO(2) + FONDO(3) + FONDO(4)
        TTMORA = MORA(1) + MORA(2) + MORA(3) + MORA(4)
        TTMULTA = MULTA(1) + MULTA(2) + MULTA(3) + MULTA(4)
        TTDESCU = DESCU(1) + DESCU(2) + DESCU(3) + DESCU(4)
        TTTASA = TTTASA - TTDESCU
        TTTASA = Int(TTTASA * 100)
        TTFONDO = Int(TTFONDO * 100)
        TTMORA = Int(TTMORA * 100)

        CODIGOXP = Format(REG, "0000") + Format(CLAVE, "0000")
        CODIGOX = Format(REG, "0000") + Format(CLAVE, "0000") + Format(TTTASA, "00000000") + Format(TTMORA, "00000000") + Format(TTMULTA, "00000000")
        TextBox62.Text = Code128a(CODIGOX, 0)

        REM        Dim bc = CreateObject("Bytescout.BarCode.BarCode")
        REM        bc.Symbology = SymbologyType.Code128 '1 = Code39 tipo de simbología
        REM        bc.Value = CODIGOX
        REM        bc.SaveImage(PAT + "ARCHIVOS\Code39.jpg")
        Dim objWord As Object
        Dim objSelection As Object
        Dim objDoc As Object
        ' referencia a la aplicación  
        objWord = CreateObject("Word.Application")
        ' referencia al nuevo documento  
        objDoc = objWord.Documents.open(PAT + "ARCHIVOS\BOLETAS.DOC")
        ' referencia a la selección  
        objSelection = objWord.Selection
        With objSelection
            ' formato de fuente para el título  
            PASO = 0
            PARA = "PARA EL CONTRIBUYENTE"
            .InlineShapes.AddPicture(PAT + "LOGO TASA COMERCIAL.jpg")
10:         .Font.Name = "Verdana"
            .Font.Size = "8" ' tamaño  
            .TypeText("DECLARACION JURADA           FECHA DE EMISION " + Trim(TextBox51.Text) + vbCrLf)
            .Font.Size = "8"
            .font.bold = True
            .TypeText("---------------------------------------------------------------------------------------------" + vbCrLf)
            .TypeText("REGISTRO " + Format(REG, "0000") + "  PERIODO " + Format(PER, "00") + Space(5) + "AÑO " + Format(ANO, "0000") + "  VENCIMIENTO " + FECHAV + vbCrLf)
            .TypeText("---------------------------------------------------------------------------------------------" + vbCrLf)
            .font.bold = False
            .TypeText("RAZON SOCIAL " + NOMBRE + Space(10) + "CUIT    " + CUIT + vbCrLf)
            .TypeText("UBICACION" + Space(7) + UBICA + Space(20) + vbCrLf)
            .TypeText("DOMICILIO" + Space(7) + DOM + "     " + LOCA + vbCrLf)
            .font.bold = True
            .TypeText("------------------------------------------------------------------------------------------------" + vbCrLf)
            .TypeText(Space(5) + "ACTIVIDAD" + Space(15) + "IMPONIBLE" + Space(11) + "ALIC" + Space(8) + "MINIMO" + Space(7) + "VALOR TASA" + vbCrLf)
            .TypeText("------------------------------------------------------------------------------------------------" + vbCrLf)
            .font.bold = False
            If TASA(1) <> 0 Then
                DEBI = Format(IMPONI(1), "$###,###,##0.00")
                DEBITO = Strings.Right(DEBI, 14)
                LE = Len(DEBITO)
                RESTO = 14 - LE
                NL = Space(RESTO) + DEBITO

                DEBI1 = Format(ALICU(1), "##0.00")
                DEBITO1 = Strings.Right(DEBI1, 6)
                LE1 = Len(DEBITO1)
                RESTO1 = 6 - LE1
                NL1 = Space(RESTO1) + DEBITO1

                DEBI2 = Format(MINI(1), "###,##0.00")
                DEBITO2 = Strings.Right(DEBI2, 10)
                LE2 = Len(DEBITO2)
                RESTO2 = 10 - LE2
                NL2 = Space(RESTO2) + DEBITO2

                DEBI3 = Format(TASA(1), "###,##0.00")
                DEBITO3 = Strings.Right(DEBI3, 10)
                LE3 = Len(DEBITO3)
                RESTO3 = 10 - LE3
                NL3 = Space(RESTO3) + DEBITO3
                .TypeText(ACT1 + vbTab + vbTab + NL + vbTab + vbTab + NL1 + vbTab + NL2 + vbTab + NL3 + vbCrLf)
            Else
                .TypeText(vbCrLf)
            End If
            If TASA(2) <> 0 Then
                DEBI = Format(IMPONI(2), "$###,###,##0.00")
                DEBITO = Strings.Right(DEBI, 14)
                LE = Len(DEBITO)
                RESTO = 14 - LE
                NL = Space(RESTO) + DEBITO

                DEBI1 = Format(ALICU(2), "##0.00")
                DEBITO1 = Strings.Right(DEBI1, 6)
                LE1 = Len(DEBITO1)
                RESTO1 = 6 - LE1
                NL1 = Space(RESTO1) + DEBITO1

                DEBI2 = Format(MINI(2), "###,##0.00")
                DEBITO2 = Strings.Right(DEBI2, 10)
                LE2 = Len(DEBITO2)
                RESTO2 = 10 - LE2
                NL2 = Space(RESTO2) + DEBITO2

                DEBI3 = Format(TASA(2), "###,##0.00")
                DEBITO3 = Strings.Right(DEBI3, 10)
                LE3 = Len(DEBITO3)
                RESTO3 = 10 - LE3
                NL3 = Space(RESTO3) + DEBITO3
                .TypeText(ACT2 + vbTab + vbTab + NL + vbTab + vbTab + NL1 + vbTab + NL2 + vbTab + NL3 + vbCrLf)
            Else
                .TypeText(vbCrLf)
            End If
            If TASA(3) <> 0 Then
                DEBI = Format(IMPONI(3), "###,###,##0.00")
                DEBITO = Strings.Right(DEBI, 14)
                LE = Len(DEBITO)
                RESTO = 14 - LE
                NL = Space(RESTO) + DEBITO

                DEBI1 = Format(ALICU(3), "##0.00")
                DEBITO1 = Strings.Right(DEBI1, 6)
                LE1 = Len(DEBITO1)
                RESTO1 = 6 - LE1
                NL1 = Space(RESTO1) + DEBITO1

                DEBI2 = Format(MINI(3), "###,##0.00")
                DEBITO2 = Strings.Right(DEBI2, 10)
                LE2 = Len(DEBITO2)
                RESTO2 = 10 - LE2
                NL2 = Space(RESTO2) + DEBITO2

                DEBI3 = Format(TASA(3), "###,##0.00")
                DEBITO3 = Strings.Right(DEBI3, 10)
                LE3 = Len(DEBITO3)
                RESTO3 = 10 - LE3
                NL3 = Space(RESTO3) + DEBITO3
                .TypeText(ACT3 + vbTab + vbTab + NL + vbTab + vbTab + NL1 + vbTab + NL2 + vbTab + NL3 + vbCrLf)
            Else
                .TypeText(vbCrLf)
            End If
            If TASA(4) <> 0 Then
                DEBI = Format(IMPONI(4), "###,###,##0.00")
                DEBITO = Strings.Right(DEBI, 14)
                LE = Len(DEBITO)
                RESTO = 14 - LE
                NL = Space(RESTO) + DEBITO

                DEBI1 = Format(ALICU(4), "##0.00")
                DEBITO1 = Strings.Right(DEBI1, 6)
                LE1 = Len(DEBITO1)
                RESTO1 = 6 - LE1
                NL1 = Space(RESTO1) + DEBITO1

                DEBI2 = Format(MINI(4), "###,##0.00")
                DEBITO2 = Strings.Right(DEBI2, 10)
                LE2 = Len(DEBITO2)
                RESTO2 = 10 - LE2
                NL2 = Space(RESTO2) + DEBITO2

                DEBI3 = Format(TASA(4), "###,##0.00")
                DEBITO3 = Strings.Right(DEBI3, 10)
                LE3 = Len(DEBITO3)
                RESTO3 = 10 - LE3
                NL3 = Space(RESTO3) + DEBITO3
                .TypeText(ACT3 + vbTab + vbTab + NL + vbTab + vbTab + NL1 + vbTab + NL2 + vbTab + NL3 + vbCrLf)
            Else
                .TypeText(vbCrLf)
            End If
            .font.bold = True
            .TypeText("-----------------------------------------------------------------------------------------------" + vbCrLf)
            .TypeText("T.TASA" + Space(15) + "FONDO" + Space(12) + "INTERES" + Space(10) + "MULTA" + Space(10) + "RETENC" + Space(10) + "TOTAL" + vbCrLf)
            .TypeText("-----------------------------------------------------------------------------------------------" + vbCrLf)
            .font.bold = False

            TTASA = TASA(1) + TASA(2) + TASA(3) + TASA(4)
            TFONDO = FONDO(1) + FONDO(2) + FONDO(3) + FONDO(4)
            TMORA = MORA(1) + MORA(2) + MORA(3) + MORA(4)
            TMULTA = MULTA(1) + MULTA(2) + MULTA(3) + MULTA(4)
            TDESCU = DESCU(1) + DESCU(2) + DESCU(3) + DESCU(4)

            DEBI = Format(TTASA, "##,###,##0.00")
            DEBITO = Strings.Right(DEBI, 13)
            LE = Len(DEBITO)
            RESTO = 13 - LE
            NL = Space(RESTO) + DEBITO

            DEBI1 = Format(TFONDO, "###,##0.00")
            DEBITO1 = Strings.Right(DEBI1, 10)
            LE1 = Len(DEBITO1)
            RESTO1 = 10 - LE1
            NL1 = Space(RESTO1) + DEBITO1

            DEBI2 = Format(TMORA, "###,##0.00")
            DEBITO2 = Strings.Right(DEBI2, 10)
            LE2 = Len(DEBITO2)
            RESTO2 = 10 - LE2
            NL2 = Space(RESTO2) + DEBITO2

            DEBI3 = Format(TMULTA, "###,##0.00")
            DEBITO3 = Strings.Right(DEBI3, 10)
            LE3 = Len(DEBITO3)
            RESTO3 = 10 - LE3
            NL3 = Space(RESTO3) + DEBITO3

            DEBI4 = Format(TDESCU, "###,##0.00")
            DEBITO4 = Strings.Right(DEBI4, 10)
            LE4 = Len(DEBITO4)
            RESTO4 = 10 - LE4
            NL4 = Space(RESTO4) + DEBITO4

            TGRAL = TTASA + TFONDO + TMORA + TMULTA - TDESCU

            DEBI5 = Format(TGRAL, "##,###,##0.00")
            DEBITO5 = Strings.Right(DEBI5, 13)
            LE5 = Len(DEBITO5)
            RESTO5 = 13 - LE5
            NL5 = Space(RESTO5) + DEBITO5
            .TypeText(NL + vbTab + NL1 + vbTab + NL2 + vbTab + NL3 + vbTab + NL4 + vbTab + NL5 + vbCrLf)
            .TypeText(vbCrLf)
            .TypeText("SON PESOS: " + Trim(TextBox61.Text) + vbCrLf)
            If Len(Trim(TextBox60.Text)) <> 0 Then
                .TypeText("ORDENES DE PAGOS " + Trim(TextBox60.Text) + vbCrLf)
                .TypeText(vbCrLf)
            Else
                .TypeText(vbCrLf)
                .TypeText(vbCrLf)
            End If
            .TypeText("F I R M A ______________   ACLARACION ________________  D N I  _______________" + vbCrLf)
            PASO = PASO + 1
            .font.bold = True
            .TypeText(PARA + vbCrLf)
            .TypeText("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" + vbCrLf)
            .font.bold = False
            PARA = "PARA EL COMPUTOS"
            If PASO = 1 Then GoTo 10
            .font.bold = True
            .TypeText("---------------------------------------------------------------------------------------------" + vbCrLf)
            .TypeText("REGISTRO " + Format(REG, "0000") + "  PERIODO " + Format(PER, "00") + Space(5) + "AÑO " + Format(ANO, "0000") + "  VENCIMIENTO " + FECHAV + vbCrLf)
            .TypeText("---------------------------------------------------------------------------------------------" + vbCrLf)
            .font.bold = False
            .TypeText("RAZON SOCIAL " + NOMBRE + "     CUIT" + Space(16) + CUIT + vbCrLf)
            .TypeText("UBICACION" + Space(7) + UBICA + Space(20) + vbCrLf)
            REM            .TypeText("DOMICILIO" + Space(7) + DOM + "     " + LOCA + vbCrLf)
            .font.bold = True
            .TypeText("-----------------------------------------------------------------------------------------------" + vbCrLf)
            .TypeText("T.TASA" + Space(15) + "FONDO" + Space(12) + "INTERES" + Space(10) + "MULTA" + Space(10) + "RETENC" + Space(10) + "TOTAL" + vbCrLf)
            .TypeText("-----------------------------------------------------------------------------------------------" + vbCrLf)
            .font.bold = False

            TTASA = TASA(1) + TASA(2) + TASA(3) + TASA(4)
            TFONDO = FONDO(1) + FONDO(2) + FONDO(3) + FONDO(4)
            TMORA = MORA(1) + MORA(2) + MORA(3) + MORA(4)
            TMULTA = MULTA(1) + MULTA(2) + MULTA(3) + MULTA(4)
            TDESCU = DESCU(1) + DESCU(2) + DESCU(3) + DESCU(4)

            DEBI = Format(TTASA, "##,###,##0.00")
            DEBITO = Strings.Right(DEBI, 13)
            LE = Len(DEBITO)
            RESTO = 13 - LE
            NL = Space(RESTO) + DEBITO

            DEBI1 = Format(TFONDO, "###,##0.00")
            DEBITO1 = Strings.Right(DEBI1, 10)
            LE1 = Len(DEBITO1)
            RESTO1 = 10 - LE1
            NL1 = Space(RESTO1) + DEBITO1

            DEBI2 = Format(TMORA, "###,##0.00")
            DEBITO2 = Strings.Right(DEBI2, 10)
            LE2 = Len(DEBITO2)
            RESTO2 = 10 - LE2
            NL2 = Space(RESTO2) + DEBITO2

            DEBI3 = Format(TMULTA, "###,##0.00")
            DEBITO3 = Strings.Right(DEBI3, 10)
            LE3 = Len(DEBITO3)
            RESTO3 = 10 - LE3
            NL3 = Space(RESTO3) + DEBITO3

            DEBI4 = Format(TDESCU, "###,##0.00")
            DEBITO4 = Strings.Right(DEBI4, 10)
            LE4 = Len(DEBITO4)
            RESTO4 = 10 - LE4
            NL4 = Space(RESTO4) + DEBITO4

            TGRAL = TTASA + TFONDO + TMORA + TMULTA - TDESCU

            DEBI5 = Format(TGRAL, "##,###,##0.00")
            DEBITO5 = Strings.Right(DEBI5, 13)
            LE5 = Len(DEBITO5)
            RESTO5 = 13 - LE5
            NL5 = Space(RESTO5) + DEBITO5
            .TypeText(NL + vbTab + NL1 + vbTab + NL2 + vbTab + NL3 + vbTab + NL4 + vbTab + NL5 + vbCrLf)
            .font.bold = True
            .TypeText("-----------------------------------------------------------------------------------------------" + vbCrLf)
            .TypeText("PARA CAJA" + vbCrLf)
            .font.bold = False

            .Font.Name = "code 128"
            .Font.Size = "30" ' tamaño  

            .TypeText(TextBox62.Text)

            REM            .TypeText(CODIGOX)
            REM            .InlineShapes.AddPicture(PAT + "ARCHIVOS\CODE39.jpg", LinkToFile:=False, SaveWithDocument:=True)
        End With
        With objWord.ActiveDocument
            .SaveAs(PAT + "archivo.doc")
            'Abre el documento  
            objWord.Documents.Open(PAT + "archivo.doc")

            ' Imprime el documento activo con Printout  
            objWord.ActiveDocument.Printout()

            ' Cierra el documento  
            objWord.Quit()

            ' Elimina la referencia  
            objWord = Nothing


            REM .Close()
        End With
        REM objWord.Quit()

        objSelection = Nothing
        objDoc = Nothing
        objWord = Nothing
        FileOpen(1, PAT + "ARCHIVOS\" + CODIGOXP + ".DAT", OpenMode.Random, OpenAccess.ReadWrite, OpenShare.Shared, 142)
        Dim CRED As New CREDIX
        FileGet(1, CRED, 1)
        UG = Val(CRED.F)
        UG = 1
        NI = Val(TextBox63.Text)
        If TASA(1) <> 0 Then
            FECC$ = Trim(TextBox51.Text)
            CRED.F = FECC$
            CRED.R = Str$(REG)
            CRED.N = Str$(NI)
            CRED.ANO = Format(ANO, "0000")
            CRED.PX = Format(PER, "00")
            CRED.C = Str$(IMPONI(1))
            CRED.i = Str$(TASA(1))
            CRED.PL = "0"
            CRED.FDO = Str$(FONDO(1))
            CRED.MOR = Str$(MORA(1))
            CRED.MULTA = Str$(MULTA(1))
            CRED.DESCU = Str$(DESCU(1))
            CRED.ORDE = Str$(CLAVE)
            CRED.ACTIV = Str$(Val(ACT1))
            UG = UG + 1
            FilePut(1, CRED, UG)
            CRED.F = Str$(UG)
            FilePut(1, CRED, 1)
        End If
        If TASA(2) <> 0 Then
            FECC$ = Trim(TextBox51.Text)
            CRED.F = FECC$
            CRED.R = Str$(REG)
            CRED.N = Str$(NI)
            CRED.ANO = Format(ANO, "0000")
            CRED.PX = Format(PER, "00")
            CRED.C = Str$(IMPONI(2))
            CRED.i = Str$(TASA(2))
            CRED.PL = "0"
            CRED.FDO = Str$(FONDO(2))
            CRED.MOR = Str$(MORA(2))
            CRED.MULTA = Str$(MULTA(2))
            CRED.DESCU = Str$(DESCU(2))
            CRED.ORDE = Str$(CLAVE)
            CRED.ACTIV = Str$(Val(ACT2))
            UG = UG + 1
            FilePut(1, CRED, UG)
            CRED.F = Str$(UG)
            FilePut(1, CRED, 1)
        End If
        If TASA(3) <> 0 Then
            FECC$ = Trim(TextBox51.Text)
            CRED.F = FECC$
            CRED.R = Str$(REG)
            CRED.N = Str$(NI)
            CRED.ANO = Format(ANO, "0000")
            CRED.PX = Format(PER, "00")
            CRED.C = Str$(IMPONI(3))
            CRED.i = Str$(TASA(3))
            CRED.PL = "0"
            CRED.FDO = Str$(FONDO(3))
            CRED.MOR = Str$(MORA(3))
            CRED.MULTA = Str$(MULTA(3))
            CRED.DESCU = Str$(DESCU(3))
            CRED.ORDE = Str$(CLAVE)
            CRED.ACTIV = Str$(Val(ACT3))
            UG = UG + 1
            FilePut(1, CRED, UG)
            CRED.F = Str$(UG)
            FilePut(1, CRED, 1)
        End If
        If TASA(4) <> 0 Then
            FECC$ = Trim(TextBox51.Text)
            CRED.F = FECC$
            CRED.R = Str$(REG)
            CRED.N = Str$(NI)
            CRED.ANO = Format(ANO, "0000")
            CRED.PX = Format(PER, "00")
            CRED.C = Str$(IMPONI(4))
            CRED.i = Str$(TASA(4))
            CRED.PL = "0"
            CRED.FDO = Str$(FONDO(4))
            CRED.MOR = Str$(MORA(4))
            CRED.MULTA = Str$(MULTA(4))
            CRED.DESCU = Str$(DESCU(4))
            CRED.ORDE = Str$(CLAVE)
            CRED.ACTIV = Str$(Val(ACT4))
            UG = UG + 1
            FilePut(1, CRED, UG)
            CRED.F = Str$(UG)
            FilePut(1, CRED, 1)
        End If
        FileClose()
    End Sub

    Protected Sub TextBox9_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox9.TextChanged
        If Val(TextBox8.Text) <> 0 Then
            If Val(TextBox9.Text) <> 0 Then
                Dim ANO As Integer
                Dim PE As Integer
                Dim PAT As String
                Dim U As Integer
                PAT = System.AppDomain.CurrentDomain.BaseDirectory()
                ANO = Val(TextBox8.Text)
                PE = Val(TextBox9.Text)
                FileOpen(1, PAT + "ARCHIVOS\VENNEGO", OpenMode.Random, OpenAccess.ReadWrite, OpenShare.Shared, 113)
                Dim VEN As New VENC1
                For U = 1 To 50
                    FileGet(1, VEN, U)
                    If ANO = Val(VEN.ANO) Then GoTo 500
                Next U
                MsgBox("NO EXISTE AÑO DE BUSQUEDA, DEBERA GRABARLO", 0, "ERRORES")
                FileClose()
                Exit Sub
500:            If PE = 1 Then TextBox10.Text = VEN.FE1
                If PE = 2 Then TextBox10.Text = VEN.FE2
                If PE = 3 Then TextBox10.Text = VEN.FE3
                If PE = 4 Then TextBox10.Text = VEN.FE4
                If PE = 5 Then TextBox10.Text = VEN.FE5
                If PE = 6 Then TextBox10.Text = VEN.FE6
                If PE = 7 Then TextBox10.Text = VEN.FE7
                If PE = 8 Then TextBox10.Text = VEN.FE8
                If PE = 9 Then TextBox10.Text = VEN.FE9
                If PE = 10 Then TextBox10.Text = VEN.FE10
                If PE = 11 Then TextBox10.Text = VEN.FE11
                If PE = 12 Then TextBox10.Text = VEN.FE12
                TextBox10.Text = Mid$(TextBox10.Text, 1, 2) + "/" + Mid$(TextBox10.Text, 3, 2) + "/" + Mid$(TextBox10.Text, 5, 4)
                FileClose()
                TextBox27.Focus()
            End If
        End If
    End Sub

    Protected Sub TextBox27_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox27.TextChanged
        If Val(TextBox27.Text) <> 0 Then
            If Val(TextBox8.Text) <> 0 Or Val(TextBox9.Text) <> 0 Then
                Dim datTim1 As Date = TextBox10.Text
                Dim datTim2 As Date = TextBox51.Text
                Dim wD As Long = DateDiff(DateInterval.Day, datTim1, datTim2)
                Dim ALIC As Double
                Dim MINI As Double
                Dim IMPO As Double
                Dim TASA As Double
                Dim MORA As Double
                Dim MULTA As Double
                Dim DESCU As Double
                Dim PMORA As Double
                Dim PMULTA As Double
                Dim PFDO As Double
                Dim FDO As Double
                ALIC = Val(TextBox19.Text)
                MINI = Val(TextBox23.Text)
                IMPO = Val(TextBox27.Text)
                PFDO = Val(TextBox54.Text)
                PFDO = PFDO / 100
                PMORA = Val(TextBox52.Text)
                PMORA = PMORA / 100
                PMULTA = Val(TextBox53.Text)
                PMULTA = PMULTA / 100
                DESCU = Val(TextBox56.Text)
                TASA = IMPO * (ALIC / 100)
                If TASA < MINI Then TASA = MINI
                FDO = Val(TASA * PFDO)
                If wD <> 0 Then
                    MORA = (TASA + FDO) * ((PMORA / 30) * wD)
                    MULTA = (TASA + FDO) * ((PMULTA / 30) * wD)
                End If
                TASA = Int((TASA * 100) + 0.5) / 100
                FDO = Int((FDO * 100) + 0.5) / 100
                MORA = Int((MORA * 100) + 0.5) / 100
                MULTA = Int((MULTA * 100) + 0.5) / 100
                TextBox31.Text = Str$(TASA)
                TextBox35.Text = Str$(FDO)
                TextBox39.Text = Str$(MORA)
                TextBox43.Text = Str$(MULTA)
                TextBox47.Text = Str$(TASA + FDO + MORA + MULTA)
                TextBox55.Text = Str$(Val(TextBox47.Text) + Val(TextBox48.Text) + Val(TextBox49.Text) + Val(TextBox50.Text))
                If Val(TextBox55.Text) <> 0 Then
                    REM     Dim CODIGO As New TECIT.TBarCode.Barcode
                    REM     CODIGO.Draw("0000000")
                    Dim S51 As String
                    Dim TOTAL As Double
                    Dim ENL As String
                    Dim ENLTR As String
                    S51 = ""
                    TOTAL = Val(TextBox55.Text)
                    If TOTAL < -0.01 Then TOTAL = (TOTAL * -1)
                    TOTAL = Int((TOTAL * 100) + 0.5) / 100
                    ENL$ = Trim(Str$(TOTAL))
                    ENLTR = ENLETRAS(ENL)
                    If Mid$(TextBox55.Text, 1, 1) = "-" Then ENLTR = "menos " + ENLTR
                    S51 = Trim(ENLTR)
                    TextBox61.Text = Trim(S51)
                    TextBox56.Focus()
                End If
            Else
                MsgBox("FALTAN DATOS, (AÑO, PERIODO O FECHA DE VENCIMIENTO")
                Exit Sub
            End If
        End If
    End Sub

    Protected Sub TextBox56_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox56.TextChanged
        If Val(TextBox56.Text) <> 0 Then
            TextBox47.Text = Str$(Val(TextBox31.Text) + Val(TextBox35.Text) + Val(TextBox39.Text) + Val(TextBox43.Text) - Val(TextBox56.Text))
            TextBox55.Text = Str$(Val(TextBox47.Text) + Val(TextBox48.Text) + Val(TextBox49.Text) + Val(TextBox50.Text))
            If Val(TextBox55.Text) <> 0 Then
                Dim S51 As String
                Dim TOTAL As Double
                Dim ENL As String
                Dim ENLTR As String
                S51 = ""
                TOTAL = Val(TextBox55.Text)
                If TOTAL < -0.01 Then TOTAL = (TOTAL * -1)
                TOTAL = Int((TOTAL * 100) + 0.5) / 100
                ENL$ = Trim(Str$(TOTAL))
                ENLTR = ENLETRAS(ENL)
                If Mid$(TextBox55.Text, 1, 1) = "-" Then ENLTR = "menos " + ENLTR
                S51 = Trim(ENLTR)
                TextBox61.Text = Trim(S51)
            End If
        End If
        TextBox28.Focus()
    End Sub

    Protected Sub TextBox57_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox57.TextChanged
        If Val(TextBox57.Text) <> 0 Then
            TextBox48.Text = Str$(Val(TextBox32.Text) + Val(TextBox36.Text) + Val(TextBox40.Text) + Val(TextBox44.Text) - Val(TextBox57.Text))
            TextBox55.Text = Str$(Val(TextBox47.Text) + Val(TextBox48.Text) + Val(TextBox49.Text) + Val(TextBox50.Text))
            If Val(TextBox55.Text) <> 0 Then
                Dim S51 As String
                Dim TOTAL As Double
                Dim ENL As String
                Dim ENLTR As String
                S51 = ""
                TOTAL = Val(TextBox55.Text)
                If TOTAL < -0.01 Then TOTAL = (TOTAL * -1)
                TOTAL = Int((TOTAL * 100) + 0.5) / 100
                ENL$ = Trim(Str$(TOTAL))
                ENLTR = ENLETRAS(ENL)
                If Mid$(TextBox55.Text, 1, 1) = "-" Then ENLTR = "menos " + ENLTR
                S51 = Trim(ENLTR)
                TextBox61.Text = Trim(S51)
            End If
        End If
        TextBox29.Focus()

    End Sub

    Protected Sub TextBox58_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox58.TextChanged
        If Val(TextBox58.Text) <> 0 Then
            TextBox49.Text = Str$(Val(TextBox33.Text) + Val(TextBox37.Text) + Val(TextBox41.Text) + Val(TextBox45.Text) - Val(TextBox58.Text))
            TextBox55.Text = Str$(Val(TextBox47.Text) + Val(TextBox48.Text) + Val(TextBox49.Text) + Val(TextBox50.Text))
            If Val(TextBox55.Text) <> 0 Then
                Dim S51 As String
                Dim TOTAL As Double
                Dim ENL As String
                Dim ENLTR As String
                S51 = ""
                TOTAL = Val(TextBox55.Text)
                If TOTAL < -0.01 Then TOTAL = (TOTAL * -1)
                TOTAL = Int((TOTAL * 100) + 0.5) / 100
                ENL$ = Trim(Str$(TOTAL))
                ENLTR = ENLETRAS(ENL)
                If Mid$(TextBox55.Text, 1, 1) = "-" Then ENLTR = "menos " + ENLTR
                S51 = Trim(ENLTR)
                TextBox61.Text = Trim(S51)
            End If
        End If
        TextBox30.Focus()
    End Sub

    Protected Sub TextBox59_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox59.TextChanged
        If Val(TextBox59.Text) <> 0 Then
            TextBox50.Text = Str$(Val(TextBox34.Text) + Val(TextBox38.Text) + Val(TextBox42.Text) + Val(TextBox46.Text) - Val(TextBox59.Text))
            TextBox55.Text = Str$(Val(TextBox47.Text) + Val(TextBox48.Text) + Val(TextBox49.Text) + Val(TextBox50.Text))
            If Val(TextBox55.Text) <> 0 Then
                Dim S51 As String
                Dim TOTAL As Double
                Dim ENL As String
                Dim ENLTR As String
                S51 = ""
                TOTAL = Val(TextBox55.Text)
                If TOTAL < -0.01 Then TOTAL = (TOTAL * -1)
                TOTAL = Int((TOTAL * 100) + 0.5) / 100
                ENL$ = Trim(Str$(TOTAL))
                ENLTR = ENLETRAS(ENL)
                If Mid$(TextBox55.Text, 1, 1) = "-" Then ENLTR = "menos " + ENLTR
                S51 = Trim(ENLTR)
                TextBox61.Text = Trim(S51)
            End If
        End If
        TextBox60.Focus()
    End Sub

    Protected Sub TextBox28_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox28.TextChanged
        If Val(TextBox28.Text) <> 0 Then
            If Val(TextBox8.Text) <> 0 Or Val(TextBox9.Text) <> 0 Then
                Dim datTim1 As Date = TextBox10.Text
                Dim datTim2 As Date = TextBox51.Text
                Dim wD As Long = DateDiff(DateInterval.Day, datTim1, datTim2)
                Dim ALIC As Double
                Dim MINI As Double
                Dim IMPO As Double
                Dim TASA As Double
                Dim MORA As Double
                Dim MULTA As Double
                Dim DESCU As Double
                Dim PMORA As Double
                Dim PMULTA As Double
                Dim PFDO As Double
                Dim FDO As Double
                ALIC = Val(TextBox20.Text)
                MINI = Val(TextBox24.Text)
                IMPO = Val(TextBox28.Text)
                PFDO = Val(TextBox54.Text)
                PFDO = PFDO / 100
                PMORA = Val(TextBox52.Text)
                PMORA = PMORA / 100
                PMULTA = Val(TextBox53.Text)
                PMULTA = PMULTA / 100
                DESCU = Val(TextBox56.Text)
                TASA = IMPO * (ALIC / 100)
                If TASA < MINI Then TASA = MINI
                FDO = Val(TASA * PFDO)
                If wD <> 0 Then
                    MORA = (TASA + FDO) * ((PMORA / 30) * wD)
                    MULTA = (TASA + FDO) * ((PMULTA / 30) * wD)
                End If
                TASA = Int((TASA * 100) + 0.5) / 100
                FDO = Int((FDO * 100) + 0.5) / 100
                MORA = Int((MORA * 100) + 0.5) / 100
                MULTA = Int((MULTA * 100) + 0.5) / 100
                TextBox32.Text = Str$(TASA)
                TextBox36.Text = Str$(FDO)
                TextBox40.Text = Str$(MORA)
                TextBox44.Text = Str$(MULTA)
                TextBox48.Text = Str$(TASA + FDO + MORA + MULTA)
                TextBox55.Text = Str$(Val(TextBox47.Text) + Val(TextBox48.Text) + Val(TextBox49.Text) + Val(TextBox50.Text))
                If Val(TextBox55.Text) <> 0 Then
                    REM     Dim CODIGO As New TECIT.TBarCode.Barcode
                    REM     CODIGO.Draw("0000000")
                    Dim S51 As String
                    Dim TOTAL As Double
                    Dim ENL As String
                    Dim ENLTR As String
                    S51 = ""
                    TOTAL = Val(TextBox55.Text)
                    If TOTAL < -0.01 Then TOTAL = (TOTAL * -1)
                    TOTAL = Int((TOTAL * 100) + 0.5) / 100
                    ENL$ = Trim(Str$(TOTAL))
                    ENLTR = ENLETRAS(ENL)
                    If Mid$(TextBox55.Text, 1, 1) = "-" Then ENLTR = "menos " + ENLTR
                    S51 = Trim(ENLTR)
                    TextBox61.Text = Trim(S51)
                    TextBox57.Focus()
                End If
            Else
                MsgBox("FALTAN DATOS, (AÑO, PERIODO O FECHA DE VENCIMIENTO")
                Exit Sub
            End If
        End If
    End Sub

    Protected Sub TextBox29_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox29.TextChanged
        If Val(TextBox29.Text) <> 0 Then
            If Val(TextBox8.Text) <> 0 Or Val(TextBox9.Text) <> 0 Then
                Dim datTim1 As Date = TextBox10.Text
                Dim datTim2 As Date = TextBox51.Text
                Dim wD As Long = DateDiff(DateInterval.Day, datTim1, datTim2)
                Dim ALIC As Double
                Dim MINI As Double
                Dim IMPO As Double
                Dim TASA As Double
                Dim MORA As Double
                Dim MULTA As Double
                Dim DESCU As Double
                Dim PMORA As Double
                Dim PMULTA As Double
                Dim PFDO As Double
                Dim FDO As Double
                ALIC = Val(TextBox22.Text)
                MINI = Val(TextBox25.Text)
                IMPO = Val(TextBox29.Text)
                PFDO = Val(TextBox54.Text)
                PFDO = PFDO / 100
                PMORA = Val(TextBox52.Text)
                PMORA = PMORA / 100
                PMULTA = Val(TextBox53.Text)
                PMULTA = PMULTA / 100
                DESCU = Val(TextBox56.Text)
                TASA = IMPO * (ALIC / 100)
                If TASA < MINI Then TASA = MINI
                FDO = Val(TASA * PFDO)
                If wD <> 0 Then
                    MORA = (TASA + FDO) * ((PMORA / 30) * wD)
                    MULTA = (TASA + FDO) * ((PMULTA / 30) * wD)
                End If
                TASA = Int((TASA * 100) + 0.5) / 100
                FDO = Int((FDO * 100) + 0.5) / 100
                MORA = Int((MORA * 100) + 0.5) / 100
                MULTA = Int((MULTA * 100) + 0.5) / 100
                TextBox33.Text = Str$(TASA)
                TextBox37.Text = Str$(FDO)
                TextBox41.Text = Str$(MORA)
                TextBox45.Text = Str$(MULTA)
                TextBox49.Text = Str$(TASA + FDO + MORA + MULTA)
                TextBox55.Text = Str$(Val(TextBox47.Text) + Val(TextBox48.Text) + Val(TextBox49.Text) + Val(TextBox50.Text))
                TextBox58.Focus()
            Else
                MsgBox("FALTAN DATOS, (AÑO, PERIODO O FECHA DE VENCIMIENTO")
                Exit Sub
            End If
        End If
    End Sub

    Protected Sub TextBox30_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox30.TextChanged
        If Val(TextBox30.Text) <> 0 Then
            If Val(TextBox8.Text) <> 0 Or Val(TextBox9.Text) <> 0 Then
                Dim datTim1 As Date = TextBox10.Text
                Dim datTim2 As Date = TextBox51.Text
                Dim wD As Long = DateDiff(DateInterval.Day, datTim1, datTim2)
                Dim ALIC As Double
                Dim MINI As Double
                Dim IMPO As Double
                Dim TASA As Double
                Dim MORA As Double
                Dim MULTA As Double
                Dim DESCU As Double
                Dim PMORA As Double
                Dim PMULTA As Double
                Dim PFDO As Double
                Dim FDO As Double
                ALIC = Val(TextBox21.Text)
                MINI = Val(TextBox26.Text)
                IMPO = Val(TextBox30.Text)
                PFDO = Val(TextBox54.Text)
                PFDO = PFDO / 100
                PMORA = Val(TextBox52.Text)
                PMORA = PMORA / 100
                PMULTA = Val(TextBox53.Text)
                PMULTA = PMULTA / 100
                DESCU = Val(TextBox56.Text)
                TASA = IMPO * (ALIC / 100)
                If TASA < MINI Then TASA = MINI
                FDO = Val(TASA * PFDO)
                If wD <> 0 Then
                    MORA = (TASA + FDO) * ((PMORA / 30) * wD)
                    MULTA = (TASA + FDO) * ((PMULTA / 30) * wD)
                End If
                TASA = Int((TASA * 100) + 0.5) / 100
                FDO = Int((FDO * 100) + 0.5) / 100
                MORA = Int((MORA * 100) + 0.5) / 100
                MULTA = Int((MULTA * 100) + 0.5) / 100
                TextBox34.Text = Str$(TASA)
                TextBox38.Text = Str$(FDO)
                TextBox42.Text = Str$(MORA)
                TextBox46.Text = Str$(MULTA)
                TextBox50.Text = Str$(TASA + FDO + MORA + MULTA)
                TextBox55.Text = Str$(Val(TextBox47.Text) + Val(TextBox48.Text) + Val(TextBox49.Text) + Val(TextBox50.Text))
                TextBox59.Focus()
            Else
                MsgBox("FALTAN DATOS, (AÑO, PERIODO O FECHA DE VENCIMIENTO")
                Exit Sub
            End If
        End If
    End Sub

    Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox5.Text = ""
        TextBox6.Text = ""
        TextBox7.Text = ""
        TextBox8.Text = ""
        TextBox9.Text = ""
        TextBox10.Text = ""
        TextBox11.Text = ""
        TextBox12.Text = ""
        TextBox13.Text = ""
        TextBox14.Text = ""
        TextBox15.Text = ""
        TextBox16.Text = ""
        TextBox17.Text = ""
        TextBox18.Text = ""
        TextBox19.Text = ""
        TextBox20.Text = ""
        TextBox21.Text = ""
        TextBox22.Text = ""
        TextBox23.Text = ""
        TextBox24.Text = ""
        TextBox25.Text = ""
        TextBox26.Text = ""
        TextBox27.Text = ""
        TextBox28.Text = ""
        TextBox29.Text = ""
        TextBox30.Text = ""
        TextBox31.Text = ""
        TextBox32.Text = ""
        TextBox33.Text = ""
        TextBox34.Text = ""
        TextBox35.Text = ""
        TextBox36.Text = ""
        TextBox37.Text = ""
        TextBox38.Text = ""
        TextBox39.Text = ""
        TextBox40.Text = ""
        TextBox41.Text = ""
        TextBox42.Text = ""
        TextBox43.Text = ""
        TextBox44.Text = ""
        TextBox45.Text = ""
        TextBox46.Text = ""
        TextBox47.Text = ""
        TextBox48.Text = ""
        TextBox49.Text = ""
        TextBox50.Text = ""
        TextBox55.Text = ""
        TextBox56.Text = ""
        TextBox57.Text = ""
        TextBox58.Text = ""
        TextBox59.Text = ""
        TextBox60.Text = ""
        TextBox61.Text = ""
        TextBox63.Text = ""
        TextBox1.Focus()
    End Sub

    Protected Sub TextBox55_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox55.TextChanged

    End Sub
End Class
