Link to home
Start Free TrialLog in
Avatar of cdb424ttm
cdb424ttm

asked on

Tuff counter question

This code is not working right. In the section which will test to see:
What is will do is pull 6 names and four will print on page on and 2 on the 2nd.
The mod statement is what is used to toggle between pg1 and pg2.
What I need it to do is print to 2 copies for each of the 4 name on page one and 2 copies for per name on the 2nd. So that will give me  8 copies of pg1 and 4 copies of pg2.
Total = 12 pages. If I had 3 name on page 2 then it would give me 6 of that page.
What I’m missing is some sort of counter for how many pages need to print for page one and page two. Now it will print = number of page 1 and page 2.
Please help
If UBound(temp_array) < 9 Then ‘(which it is =6 in this case)
          If (index Mod 2 = 0) Then
               oRequest.SetValue "right_1”, "to", temp_array(5)
Here is the actual code section I’m using:

For Index = 1 To Val(print_count)
     If UBound(temp_array) < 5 Then
          oRequest.SetValue "right_1", "to", temp_array(1)
          If UBound(temp_array) >= 2 Then
               oRequest.SetValue "right_2", "to", temp_array(2)
          Else
               oRequest.SetValue "right_2", "to", ""
          End If
          If UBound(temp_array) >= 3 Then
               oRequest.SetValue "right_3", "to", temp_array(3)
          Else
               oRequest.SetValue "right_3", "to", ""
          End If
          If UBound(temp_array) >= 4 Then
               oRequest.SetValue "right_4", "to", temp_array(4)
          Else
               oRequest.SetValue "right_4", "to", ""
          End If
     Else
        If UBound(temp_array) < 9 Then
          If (Index Mod 2 = 0) Then
               oRequest.SetValue "right_1", "to", temp_array(5)
               If UBound(temp_array) >= 6 Then
                    oRequest.SetValue "right_2", "to", temp_array(6)
               Else
                    oRequest.SetValue "right_2", "to", ""
               End If
               If UBound(temp_array) >= 7 Then
                    oRequest.SetValue "right_3", "to", temp_array(7)
               Else
                    oRequest.SetValue "right_3", "to", ""
               End If
               If UBound(temp_array) >= 8 Then
                    oRequest.SetValue "right_4", "to", temp_array(8)
               Else
                    oRequest.SetValue "right_4", "to", ""
               End If
          Else
               oRequest.SetValue "right_1", "to", temp_array(1)
               If UBound(temp_array) >= 2 Then
                    oRequest.SetValue "right_2", "to", temp_array(2)
               Else
                    oRequest.SetValue "right_2", "to", ""
               End If
               If UBound(temp_array) >= 3 Then
                    oRequest.SetValue "right_3", "to", temp_array(3)
               Else
                    oRequest.SetValue "right_3", "to", ""
               End If
               If UBound(temp_array) >= 4 Then
                    oRequest.SetValue "right_4", "to", temp_array(4)
               Else
                    oRequest.SetValue "right_4", "to", ""
               End If
          End If
       Else
         If UBound(temp_array) < 13 Then
               Let pg3_count = pg3_count + 1
               If Val(pg3_count) = 1 Then
                 Let nd_pg3 = 1
               End If
               If Val(pg3_count) = 2 Then
                 Let nd_pg3 = 5
               End If
               If Val(pg3_count) = 3 Then
                 Let nd_pg3 = 9
                 Let pg3_count = 0
               End If
               Let nbr = nd_pg3
               oRequest.SetValue "right_1", "to", temp_array(nbr)
               Let nbr = Val(nbr) + 1
               If UBound(temp_array) >= Val(nbr) Then
                    oRequest.SetValue "right_2", "to", temp_array(nbr)
               Else
                    oRequest.SetValue "right_2", "to", ""
               End If
               Let nbr = Val(nbr) + 1
               If UBound(temp_array) >= Val(nbr) Then
                    oRequest.SetValue "right_3", "to", temp_array(nbr)
               Else
                    oRequest.SetValue "right_3", "to", ""
               End If
               Let nbr = Val(nbr) + 1
               If UBound(temp_array) >= Val(nbr) Then
                    oRequest.SetValue "right_4", "to", temp_array(nbr)
               Else
                    oRequest.SetValue "right_4", "to", ""
               End If

ASKER CERTIFIED SOLUTION
Avatar of ___XXX_X_XXX___
___XXX_X_XXX___

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cdb424ttm
cdb424ttm

ASKER


Here is the whole chuck of code that I'm using.

Dim Temp_Array()
Dim index
Dim counter
Dim print_count
Dim stgBorr
Dim stgWaiver
Dim lend_count
Dim nd_pg3
Dim pg3_count
Dim nd_pg4
Dim pg4_count
Dim nbr
Dim pg1Borr
Dim home_count

      '----------------------------------------------
oRequest.SetValue "Right_to_Home" , "to" ,
"False"
home_count = 0

For index = 1 To Val( CDE.LT-BORROWER.BORR-NAME("Count") )
     If CDE.LT-BORROWER.RT-RESCIND(index) = True Then
          counter = counter + 1
     End If
Next
'(new defect   add homestead if prop-type = 1  2-15-02
If Val(CDE.LT-MASTER.PROP-TYPE) = 1 Then
   For index = 1 To Val( CDE.LT-BORROWER.BORR-NAME("Count") )
     If CDE.LT-BORROWER.RT-RESCIND(index) = True Then
        If CDE.LT-BORROWER.HOMESTD-WAIVER-NAME(index) <> ""
Then
          counter = counter + 1
          home_count = home_count + 1
        End If
     End If
   Next
End If
   
   If Val(home_count) <> 0 Then
      oRequest.SetValue "Right_to_Home" , "to" ,
"True"
   End If

If Val(counter) <> 0 Then
   If Val(counter) > 12 Then
      Let lend_count = 4
   Else
      If Val(counter) > 8 And Val(counter) <= 12 Then
         Let lend_count = 3
      Else
         If Val(counter) > 4 And Val(counter) <= 8 Then
            Let lend_count = 2
         Else
            Let lend_count = 1
         End If
      End If
   End If
       
   Let print_count = (Val(counter) * 2) + Val(lend_count)

ReDim Temp_Array(counter)
counter = 0
For index = 1 To Val( CDE.LT-BORROWER.BORR-NAME("Count") )
     If CDE.LT-BORROWER.RT-RESCIND(index) = True Then
          counter = counter + 1
          stgBorr = CDE.LT-BORROWER.BORR-NAME(index)
          If Val(counter) = 1 Then
             Let pg1Borr = stgBorr
          Else
             Let pg1Borr = pg1Borr & ", " & stgBorr
          End If
          If CDE.LT-BORROWER.POA-FLAG(index) = True Then
             stgBorr = stgBorr & vbnewline & "By: " &
CDE.LT-BORROWER.POA-NAME(index)
          End If
          Temp_Array(counter) = stgBorr
     End If
Next
'(new defect   add homestead if prop-type = 1  2-15-02
If Val(CDE.LT-MASTER.PROP-TYPE) = 1 Then
   For index = 1 To Val( CDE.LT-BORROWER.BORR-NAME("Count") )
     If CDE.LT-BORROWER.RT-RESCIND(index) = True Then
        If CDE.LT-BORROWER.HOMESTD-WAIVER-NAME(index) <> ""
Then
          counter = counter + 1
          stgWaiver = CDE.LT-BORROWER.HOMESTD-WAIVER-NAME(index) & 
"*"
          Let pg1Borr = pg1Borr & ", " & stgWaiver
          Temp_Array(counter) = stgWaiver
        End If
     End If
   Next
End If


For index = 1 To Val(print_count)
     If UBound(temp_array) < 5 Then
          oRequest.SetValue "right_1" , "to", temp_array(1)
          If UBound(temp_array) >= 2 Then
               oRequest.SetValue "right_2" , "to",
temp_array(2)
          Else
               oRequest.SetValue "right_2" , "to",
""
          End If
          If UBound(temp_array) >= 3 Then
               oRequest.SetValue "right_3" , "to",
temp_array(3)
          Else
               oRequest.SetValue "right_3" , "to",
""
          End If
          If UBound(temp_array) >= 4 Then
               oRequest.SetValue "right_4" , "to",
temp_array(4)
          Else
               oRequest.SetValue "right_4" , "to",
""
          End If
     Else
        If UBound(temp_array) < 9 Then
          If  (index Mod 2 = 0) Then
               oRequest.SetValue "right_1" , "to",
temp_array(5)
               If UBound(temp_array) >= 6 Then
                    oRequest.SetValue "right_2" , "to",
temp_array(6)
               Else
                    oRequest.SetValue "right_2" , "to",
""
               End If
               If UBound(temp_array) >= 7 Then
                    oRequest.SetValue "right_3" , "to",
temp_array(7)
               Else
                    oRequest.SetValue "right_3" , "to",
""
               End If
               If UBound(temp_array) >= 8 Then
                    oRequest.SetValue "right_4" , "to",
temp_array(8)
               Else
                    oRequest.SetValue "right_4" , "to",
""
               End If
          Else
               oRequest.SetValue "right_1" , "to",
temp_array(1)
               If UBound(temp_array) >= 2 Then
                    oRequest.SetValue "right_2" , "to",
temp_array(2)
               Else
                    oRequest.SetValue "right_2" , "to",
""
               End If
               If UBound(temp_array) >= 3 Then
                    oRequest.SetValue "right_3" , "to",
temp_array(3)
               Else
                    oRequest.SetValue "right_3" , "to",
""
               End If
               If UBound(temp_array) >= 4 Then
                    oRequest.SetValue "right_4" , "to",
temp_array(4)
               Else
                    oRequest.SetValue "right_4" , "to",
""
               End If
          End If
       Else
         If UBound(temp_array) < 13 Then
               Let pg3_count = pg3_count + 1
               If Val(pg3_count) = 1 Then
                 Let nd_pg3 = 1
               End If
               If Val(pg3_count) = 2 Then
                 Let nd_pg3 = 5
               End If
               If Val(pg3_count) = 3 Then
                 Let nd_pg3 = 9
                 Let pg3_count = 0
               End If
               Let nbr = nd_pg3
               oRequest.SetValue "right_1" , "to",
temp_array(nbr)
               Let nbr = Val(nbr) + 1
               If UBound(temp_array) >= Val(nbr) Then
                    oRequest.SetValue "right_2" , "to",
temp_array(nbr)
               Else
                    oRequest.SetValue "right_2" , "to",
""
               End If
               Let nbr = Val(nbr) + 1
               If UBound(temp_array) >= Val(nbr) Then
                    oRequest.SetValue "right_3" , "to",
temp_array(nbr)
               Else
                    oRequest.SetValue "right_3" , "to",
""
               End If
               Let nbr = Val(nbr) + 1
               If UBound(temp_array) >= Val(nbr) Then
                    oRequest.SetValue "right_4" , "to",
temp_array(nbr)
               Else
                    oRequest.SetValue "right_4" , "to",
""
               End If
         Else
            If UBound(temp_array) < 17 Then
               Let pg4_count = pg4_count + 1
               If Val(pg4_count) = 1 Then
                 Let nd_pg4 = 1
               End If
               If Val(pg4_count) = 2 Then
                 Let nd_pg4 = 5
               End If
               If Val(pg4_count) = 3 Then
                 Let nd_pg4 = 9
               End If
               If Val(pg4_count) = 4 Then
                 Let nd_pg4 = 13
                 Let pg4_count = 0
               End If
               Let nbr = nd_pg4
               oRequest.SetValue "right_1" , "to",
temp_array(nbr)
               Let nbr = Val(nbr) + 1
               If UBound(temp_array) >= Val(nbr) Then
                    oRequest.SetValue "right_2" , "to",
temp_array(nbr)
               Else
                    oRequest.SetValue "right_2" , "to",
""
               End If
               Let nbr = Val(nbr) + 1
               If UBound(temp_array) >= Val(nbr) Then
                    oRequest.SetValue "right_3" , "to",
temp_array(nbr)
               Else
                    oRequest.SetValue "right_3" , "to",
""
               End If
               Let nbr = Val(nbr) + 1
               If UBound(temp_array) >= Val(nbr) Then
                    oRequest.SetValue "right_4" , "to",
temp_array(nbr)
               Else
                    oRequest.SetValue "right_4" , "to",
""
               End If
 
            End If
         
         End If
       End If
     End If
     oRequest.SetValue "acrosspage" , "to" , 1
     oRequest.SetValue "pg1numborr" , "to" , 4
     oRequest.SetValue "Right_to_Borr" , "to" , pg1Borr
If Val(CDE.LT-MASTER.PROP-TYPE) = 1 Then
     oRequest.SetValue "sigline_vars" , "to" ,
"0,0,0,1,1,0,0"
Else
     oRequest.SetValue "sigline_vars" , "to" ,
"0,0,0,0,1,0,0"
            End If
            oTemplate.LoadFormData
            oForm.NoOfCopies = -1
            oForm.RelativePosition = 5
            oForm.Setcopy "File"
            AddFormToPackage
      Next
      
      
      
End If
no one can seem to help me with this go ahead and delete question.