home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l406 / 4.ddi / SELFORM.FR_ / SELFORM.bin (.txt)
Encoding:
Visual Basic Form  |  1992-10-21  |  13.7 KB  |  305 lines

  1. VERSION 2.00
  2. Begin Form frmFormSelect 
  3.    Caption         =   "Graph/Grid Select"
  4.    Height          =   2940
  5.    Left            =   3960
  6.    LinkTopic       =   "Form1"
  7.    MaxButton       =   0   'False
  8.    ScaleHeight     =   2595
  9.    ScaleWidth      =   2910
  10.    Top             =   1185
  11.    Width           =   2970
  12.    Begin CommandButton cmdCancel 
  13.       Cancel          =   -1  'True
  14.       Caption         =   "Cancel"
  15.       Height          =   375
  16.       Left            =   1500
  17.       TabIndex        =   2
  18.       Top             =   2040
  19.       Width           =   1155
  20.    End
  21.    Begin CommandButton cmdGo 
  22.       Caption         =   "cmdGo"
  23.       Enabled         =   0   'False
  24.       Height          =   375
  25.       Left            =   240
  26.       TabIndex        =   1
  27.       Top             =   2040
  28.       Width           =   1155
  29.    End
  30.    Begin ListBox lstFormSelect 
  31.       Height          =   1785
  32.       Left            =   180
  33.       MultiSelect     =   2  'Extended
  34.       TabIndex        =   0
  35.       Top             =   120
  36.       Width           =   2535
  37.    End
  38. Dim localGoalType() As String
  39. Dim localFormNumb() As Variant
  40. Dim CumGrTotal, CumGrAmtSaved, CumGrIntAmt
  41. Sub ArrayCalc (GPeriods)
  42.     'This subroutine places values into an array that are used
  43.     'in the combined graph and grid routines.
  44.     CumGrAmtSaved = 0
  45.     CumGrIntAmt = 0
  46.     CumGrTotal = 0
  47.     'set all previous values to zero
  48.     For i = 1 To GPeriods
  49.         AmtToSaveArray(i) = 0
  50.         CumAmtSavedArray(i) = 0
  51.         IntAmtArray(i) = 0
  52.         CumIntArray(i) = 0
  53.     Next i
  54.     For f = 0 To forms.Count - 1
  55.         GridThisForm = False
  56.         
  57.         'Check to see if forms(f) is one of the selected forms
  58.         For j = 0 To lstFormSelect.ListCount - 1
  59.             If lstFormSelect.List(j) = forms(f).Caption And lstFormSelect.Selected(j) = True Then
  60.                 GridThisForm = True
  61.             End If
  62.         Next j
  63.         If GridThisForm = True Then
  64.             
  65.             'Get values off of form
  66.             If forms(f).Tag = "College" Then
  67.                 AmtToSave = colpmt(Val(forms(f).txtColAnnCost), Val(forms(f).txtColIncrease) / 100, Val(forms(f).txtColIntRate) / 100, Val(forms(f).txtColAge) - Val(forms(f).txtAge), Val(forms(f).txtColYears), Val(forms(f).txtColSaved), 1)
  68.                 GiRate = Val(forms(f).txtColIntRate)
  69.                 GPer = Val(forms(f).txtColAge) - Val(forms(f).txtAge) + Val(forms(f).txtColYears) - 1
  70.                 CumAmtSaved = Val(forms(f).txtColSaved)
  71.                 GCAge = Val(forms(f).txtColAge): GAge = Val(forms(f).txtAge): GCAnnCost = Val(forms(f).txtColAnnCost): GColInc = Val(forms(f).txtColIncrease)
  72.             Else
  73.                 AmtToSave = pmt(Val(forms(f).txtGenPrice), Val(forms(f).txtGenIntRate) / 100, Val(forms(f).txtGenPer), Val(forms(f).txtGenSaved))
  74.                 GiRate = Val(forms(f).txtGenIntRate)
  75.                 GPer = Val(forms(f).txtGenPer)
  76.                 CumAmtSaved = Val(forms(f).txtGenSaved)
  77.             End If
  78.             
  79.             'Start assigning values to the arrays
  80.             CumInt = 0: IntAmt = 0: CumTotal = CumAmtSaved
  81.             For i = 1 To GPer
  82.                 AmtToSaveArray(i) = AmtToSaveArray(i) + AmtToSave
  83.                 CumAmtSaved = CumAmtSaved + AmtToSave: CumAmtSavedArray(i) = CumAmtSavedArray(i) + CumAmtSaved
  84.                 IntAmt = (CumTotal) * GiRate / 100: IntAmtArray(i) = IntAmtArray(i) + IntAmt
  85.                 CumInt = CumInt + IntAmt: CumIntArray(i) = CumIntArray(i) + CumInt
  86.                 ' Check for start of each year of College
  87.                 If i >= (Val(GCAge) - Val(GAge)) And forms(f).Tag = "College" Then
  88.                     CumTotal = CumTotal - GCAnnCost * (1 + GColInc / 100) ^ (i)
  89.                 End If
  90.                 If i = GPeriods And GType = 1 Then
  91.                     CumTotal = CumTotal - GPrice
  92.                 End If
  93.                 CumTotal = CumTotal + AmtToSave + IntAmt
  94.             Next i
  95.             
  96.             'Accumulate values for the status bar
  97.             CumGrAmtSaved = CumGrAmtSaved + CumAmtSaved
  98.             CumGrIntAmt = CumGrIntAmt + CumInt
  99.             CumGrTotal = CumGrAmtSaved + CumGrIntAmt
  100.         End If
  101.     Next f
  102. End Sub
  103. Sub cmdCancel_Click ()
  104.     Unload frmFormSelect
  105. End Sub
  106. Sub cmdGo_Click ()
  107.     screen.MousePointer = 11
  108.     If cmdGo.Caption = "Graph" Then
  109.         
  110.         'Open new instance of frmGraph
  111.         Set GenGraph(GraForm) = New frmGraph
  112.         
  113.         GenGraph(GraForm).Caption = ""
  114.         GPeriods = 0
  115.         On Error Resume Next
  116.         Err = 0
  117.         
  118.         'Iterate through all forms
  119.         For i = 0 To forms.Count - 1
  120.             'Iterate through all listed forms
  121.             For j = 0 To lstFormSelect.ListCount - 1
  122.                 'Check to see if list selection is selected and find form
  123.                 If lstFormSelect.List(j) = forms(i).Caption And lstFormSelect.Selected(j) = True Then
  124.                     If forms(i).Tag = "College" Then
  125.                         TestYears = Val(forms(i).txtColAge) - Val(forms(i).txtAge) + Val(forms(i).txtColYears) - 1
  126.                     ElseIf forms(i).Tag = "General" Then
  127.                         TestYears = Val(forms(i).txtGenPer)
  128.                     End If
  129.                     If TestYears > GPeriods Then
  130.                         GPeriods = TestYears
  131.                     End If
  132.                     ' Added to delineate graph titles on frmGraph.Caption
  133.                     If j = 0 Then
  134.                         GenGraph(GraForm).Caption = "<" + lstFormSelect.List(j) + ">"
  135.                     Else
  136.                         GenGraph(GraForm).Caption = GenGraph(GraForm).Caption + "  " + "<" + lstFormSelect.List(j) + ">"
  137.                     End If
  138.                 End If
  139.             Next j
  140.         Next i
  141.         
  142.         ' Run routine to add up each years values
  143.         ArrayCalc GPeriods
  144.         
  145.         ' Determine the maximum value
  146.         For i = 1 To GPeriods
  147.             If CumAmtSavedArray(i) + CumIntArray(i) > GGoal Then GGoal = CumAmtSavedArray(i) + CumIntArray(i)
  148.         Next i
  149.         
  150.         ' Determine Maximum Scale
  151.         intMaxScale = (Int((GGoal - 1) / 1000) + 1) * 1000
  152.         
  153.         ' Put the graph year labels on the form
  154.         For i = 0 To GPeriods - 1
  155.             If i <> 0 Then
  156.                 Load GenGraph(GraForm).lblPerNo(i)
  157.                 GenGraph(GraForm).lblPerNo(i).Left = GenGraph(GraForm).lblPerNo(i - 1).Left + GenGraph(GraForm).lblPerNo(i - 1).Width
  158.             End If
  159.             GenGraph(GraForm).lblPerNo(i).Width = 7000 / GPeriods
  160.             GenGraph(GraForm).lblPerNo(i).Caption = i + 1
  161.             GenGraph(GraForm).lblPerNo(i).Enabled = True
  162.             GenGraph(GraForm).lblPerNo(i).Visible = True
  163.         Next i
  164.         
  165.         ' Put the dollar labels on the form
  166.         For i = 0 To 9
  167.             If i <> 0 Then
  168.                 Load GenGraph(GraForm).Line3(i)
  169.                 Load GenGraph(GraForm).Label1(i)
  170.                 GenGraph(GraForm).Line3(i).Y1 = GenGraph(GraForm).Line3(i - 1).Y1 - 400
  171.                 GenGraph(GraForm).Line3(i).Y2 = GenGraph(GraForm).Line3(i - 1).Y1 - 400
  172.                 GenGraph(GraForm).Label1(i).Top = GenGraph(GraForm).Label1(i - 1).Top - 400
  173.             End If
  174.             GenGraph(GraForm).Line3(i).Visible = True
  175.             GenGraph(GraForm).Label1(i).Caption = Format$(intMaxScale / 10 * (i + 1), "$###,###")
  176.             GenGraph(GraForm).Label1(i).Enabled = True
  177.             GenGraph(GraForm).Label1(i).Visible = True
  178.         Next
  179.         
  180.         CumAmtSavedArrayTotal = 0
  181.         CumIntArrayTotal = 0
  182.         For i = 0 To (GPeriods - 1) * 2 Step 2
  183.             
  184.             ' Create Graph bar for amount saved
  185.             If i <> 0 Then Load GenGraph(GraForm).GraphBox(i)
  186.             GenGraph(GraForm).GraphBox(i).Height = CumAmtSavedArray(i / 2 + 1) * 4000 / GGoal
  187.             CumAmtSavedArrayTotal = CumAmtSavedArrayTotal + CumAmtSavedArray(i / 2 + 1)
  188.             GenGraph(GraForm).GraphBox(i).Top = 4440 - GenGraph(GraForm).GraphBox(i).Height
  189.             GenGraph(GraForm).GraphBox(i).Width = 7000 / GPeriods - 30
  190.             If i <> 0 Then GenGraph(GraForm).GraphBox(i).Left = GenGraph(GraForm).GraphBox(i - 2).Left + GenGraph(GraForm).GraphBox(i).Width + 30
  191.             GenGraph(GraForm).GraphBox(i).Visible = True
  192.             
  193.             ' Create Graph bar for interest amount
  194.             If CumIntArray(i / 2 + 1) * 4000 / GGoal >= 1 Then
  195.                 Load GenGraph(GraForm).GraphBox(i + 1)
  196.                 GenGraph(GraForm).GraphBox(i + 1).Height = CumIntArray(i / 2 + 1) * 4000 / GGoal
  197.                 CumIntArrayTotal = CumIntArrayTotal + CumIntArray(i / 2 + 1)
  198.                 GenGraph(GraForm).GraphBox(i + 1).Top = GenGraph(GraForm).GraphBox(i).Top - GenGraph(GraForm).GraphBox(i + 1).Height
  199.                 GenGraph(GraForm).GraphBox(i + 1).Width = 7000 / GPeriods - 30
  200.                 GenGraph(GraForm).GraphBox(i + 1).Left = GenGraph(GraForm).GraphBox(i).Left
  201.                 GenGraph(GraForm).GraphBox(i + 1).BackColor = QBColor(14)
  202.                 GenGraph(GraForm).GraphBox(i + 1).Visible = True
  203.             End If
  204.         Next i
  205.         
  206.         ' Assign values on status bar
  207.         GenGraph(GraForm).lblCumTotal = Format$(CumGrTotal, " $###,###,###")
  208.         GenGraph(GraForm).lblCumAmtSaved = Format$(CumGrAmtSaved, " $###,###,###")
  209.         GenGraph(GraForm).lblCumInt = Format$(CumGrIntAmt, " $###,###,###")
  210.         
  211.         GenGraph(GraForm).Show
  212.         
  213.         GraForm = GraForm + 1
  214.     Else
  215.         'Combined grid routine
  216.         
  217.         ' Open new instance of frmGrid
  218.         Set ComGrid(GriForm) = New frmGrid
  219.         
  220.         ComGrid(GriForm).Caption = ""
  221.         GPeriods = 0
  222.         On Error Resume Next
  223.         Err = 0
  224.         
  225.         'Iterate through all forms
  226.         For i = 0 To forms.Count - 1
  227.             'Iterate through all listed forms
  228.             For j = 0 To lstFormSelect.ListCount - 1
  229.                 'Check to see if list selection is selected and find form
  230.                 If lstFormSelect.List(j) = forms(i).Caption And lstFormSelect.Selected(j) = True Then
  231.                     If forms(i).Tag = "College" Then
  232.                         TestYears = Val(forms(i).txtColAge) - Val(forms(i).txtAge) + Val(forms(i).txtColYears) - 1
  233.                     ElseIf forms(i).Tag = "General" Then
  234.                         TestYears = Val(forms(i).txtGenPer)
  235.                     End If
  236.                     If TestYears > GPeriods Then
  237.                         GPeriods = TestYears
  238.                     End If
  239.                     ' Added to delineate graph titles on frmGraph.Caption
  240.                     If j = 0 Then
  241.                         ComGrid(GriForm).Caption = "<" + lstFormSelect.List(j) + ">"
  242.                     Else
  243.                         ComGrid(GriForm).Caption = ComGrid(GriForm).Caption + "  " + "<" + lstFormSelect.List(j) + ">"
  244.                     End If
  245.                 End If
  246.             Next j
  247.         Next i
  248.         
  249.         ' Set up grid
  250.         If GPeriods > 0 Then
  251.             ComGrid(GriForm).Grid1.Rows = GPeriods + 1
  252.         Else
  253.             ComGrid(GriForm).Grid1.Rows = 2
  254.         End If
  255.         ComGrid(GriForm).Grid1.Cols = 6: ComGrid(GriForm).Grid1.FixedCols = 0
  256.         ComGrid(GriForm).Grid1.ColWidth(0) = 600
  257.         ComGrid(GriForm).Grid1.RowHeight(0) = 700
  258.         ComGrid(GriForm).Grid1.ColAlignment(1) = 2
  259.         For i = 1 To 5
  260.             ComGrid(GriForm).Grid1.ColWidth(i) = 1350
  261.             ComGrid(GriForm).Grid1.ColAlignment(i) = 1
  262.         Next i
  263.         ComGrid(GriForm).Grid1.Row = 0: ComGrid(GriForm).Grid1.Col = 0: ComGrid(GriForm).Grid1.Text = "Years"
  264.         ComGrid(GriForm).Grid1.Col = 1: ComGrid(GriForm).Grid1.Text = "Amount Saved This Period"
  265.         ComGrid(GriForm).Grid1.Col = 2: ComGrid(GriForm).Grid1.Text = "Accumulated Amount Saved"
  266.         ComGrid(GriForm).Grid1.Col = 3: ComGrid(GriForm).Grid1.Text = "Interest Earned"
  267.         ComGrid(GriForm).Grid1.Col = 4: ComGrid(GriForm).Grid1.Text = "Accumulated Interest"
  268.         ComGrid(GriForm).Grid1.Col = 5: ComGrid(GriForm).Grid1.Text = "Total Accumulated Savings"
  269.         
  270.         ' Run routine to add up each years values
  271.         ArrayCalc GPeriods
  272.         
  273.         ' Start assigning values to the grid
  274.         For i = 1 To GPeriods
  275.             ComGrid(GriForm).Grid1.Row = i
  276.             ComGrid(GriForm).Grid1.Col = 0: ComGrid(GriForm).Grid1.Text = Str$(i)
  277.             ComGrid(GriForm).Grid1.Col = 1: ComGrid(GriForm).Grid1.Text = Format$(AmtToSaveArray(i), "$###,##0.00")
  278.             ComGrid(GriForm).Grid1.Col = 2: ComGrid(GriForm).Grid1.Text = Format$(CumAmtSavedArray(i), "$###,##0.00")
  279.             ComGrid(GriForm).Grid1.Col = 3: ComGrid(GriForm).Grid1.Text = Format$(IntAmtArray(i), "$###,##0.00")
  280.             ComGrid(GriForm).Grid1.Col = 4: ComGrid(GriForm).Grid1.Text = Format$(CumIntArray(i), "$###,##0.00")
  281.             ComGrid(GriForm).Grid1.Col = 5: ComGrid(GriForm).Grid1.Text = Format$(CumAmtSavedArray(i) + CumIntArray(i), "$###,##0.00")
  282.         Next i
  283.         ComGrid(GriForm).Grid1.Col = 1
  284.         ComGrid(GriForm).Grid1.Row = 1
  285.         
  286.         ' Update values to the status bar
  287.         ComGrid(GriForm).lblCumTotal = Format$(CumGrTotal, " $###,###,###")
  288.         ComGrid(GriForm).lblCumAmtSaved = Format$(CumGrAmtSaved, " $###,###,###")
  289.         ComGrid(GriForm).lblCumInt = Format$(CumGrIntAmt, " $###,###,###")
  290.         
  291.         ComGrid(GriForm).Show
  292.     End If
  293.     screen.MousePointer = 0
  294.     Unload frmFormSelect
  295. End Sub
  296. Sub lstFormSelect_Click ()
  297.     DoEnable = False
  298.     For i = 0 To lstFormSelect.ListCount - 1
  299.         If lstFormSelect.Selected(i) = True Then
  300.             DoEnable = True
  301.         End If
  302.     Next
  303.     If DoEnable Then cmdGo.Enabled = True Else cmdGo.Enabled = False
  304. End Sub
  305.