home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form frmFormSelect
- Caption = "Graph/Grid Select"
- Height = 2940
- Left = 3960
- LinkTopic = "Form1"
- MaxButton = 0 'False
- ScaleHeight = 2595
- ScaleWidth = 2910
- Top = 1185
- Width = 2970
- Begin CommandButton cmdCancel
- Cancel = -1 'True
- Caption = "Cancel"
- Height = 375
- Left = 1500
- TabIndex = 2
- Top = 2040
- Width = 1155
- End
- Begin CommandButton cmdGo
- Caption = "cmdGo"
- Enabled = 0 'False
- Height = 375
- Left = 240
- TabIndex = 1
- Top = 2040
- Width = 1155
- End
- Begin ListBox lstFormSelect
- Height = 1785
- Left = 180
- MultiSelect = 2 'Extended
- TabIndex = 0
- Top = 120
- Width = 2535
- End
- Dim localGoalType() As String
- Dim localFormNumb() As Variant
- Dim CumGrTotal, CumGrAmtSaved, CumGrIntAmt
- Sub ArrayCalc (GPeriods)
- 'This subroutine places values into an array that are used
- 'in the combined graph and grid routines.
- CumGrAmtSaved = 0
- CumGrIntAmt = 0
- CumGrTotal = 0
- 'set all previous values to zero
- For i = 1 To GPeriods
- AmtToSaveArray(i) = 0
- CumAmtSavedArray(i) = 0
- IntAmtArray(i) = 0
- CumIntArray(i) = 0
- Next i
- For f = 0 To forms.Count - 1
- GridThisForm = False
-
- 'Check to see if forms(f) is one of the selected forms
- For j = 0 To lstFormSelect.ListCount - 1
- If lstFormSelect.List(j) = forms(f).Caption And lstFormSelect.Selected(j) = True Then
- GridThisForm = True
- End If
- Next j
- If GridThisForm = True Then
-
- 'Get values off of form
- If forms(f).Tag = "College" Then
- 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)
- GiRate = Val(forms(f).txtColIntRate)
- GPer = Val(forms(f).txtColAge) - Val(forms(f).txtAge) + Val(forms(f).txtColYears) - 1
- CumAmtSaved = Val(forms(f).txtColSaved)
- GCAge = Val(forms(f).txtColAge): GAge = Val(forms(f).txtAge): GCAnnCost = Val(forms(f).txtColAnnCost): GColInc = Val(forms(f).txtColIncrease)
- Else
- AmtToSave = pmt(Val(forms(f).txtGenPrice), Val(forms(f).txtGenIntRate) / 100, Val(forms(f).txtGenPer), Val(forms(f).txtGenSaved))
- GiRate = Val(forms(f).txtGenIntRate)
- GPer = Val(forms(f).txtGenPer)
- CumAmtSaved = Val(forms(f).txtGenSaved)
- End If
-
- 'Start assigning values to the arrays
- CumInt = 0: IntAmt = 0: CumTotal = CumAmtSaved
- For i = 1 To GPer
- AmtToSaveArray(i) = AmtToSaveArray(i) + AmtToSave
- CumAmtSaved = CumAmtSaved + AmtToSave: CumAmtSavedArray(i) = CumAmtSavedArray(i) + CumAmtSaved
- IntAmt = (CumTotal) * GiRate / 100: IntAmtArray(i) = IntAmtArray(i) + IntAmt
- CumInt = CumInt + IntAmt: CumIntArray(i) = CumIntArray(i) + CumInt
- ' Check for start of each year of College
- If i >= (Val(GCAge) - Val(GAge)) And forms(f).Tag = "College" Then
- CumTotal = CumTotal - GCAnnCost * (1 + GColInc / 100) ^ (i)
- End If
- If i = GPeriods And GType = 1 Then
- CumTotal = CumTotal - GPrice
- End If
- CumTotal = CumTotal + AmtToSave + IntAmt
- Next i
-
- 'Accumulate values for the status bar
- CumGrAmtSaved = CumGrAmtSaved + CumAmtSaved
- CumGrIntAmt = CumGrIntAmt + CumInt
- CumGrTotal = CumGrAmtSaved + CumGrIntAmt
- End If
- Next f
- End Sub
- Sub cmdCancel_Click ()
- Unload frmFormSelect
- End Sub
- Sub cmdGo_Click ()
- screen.MousePointer = 11
- If cmdGo.Caption = "Graph" Then
-
- 'Open new instance of frmGraph
- Set GenGraph(GraForm) = New frmGraph
-
- GenGraph(GraForm).Caption = ""
- GPeriods = 0
- On Error Resume Next
- Err = 0
-
- 'Iterate through all forms
- For i = 0 To forms.Count - 1
- 'Iterate through all listed forms
- For j = 0 To lstFormSelect.ListCount - 1
- 'Check to see if list selection is selected and find form
- If lstFormSelect.List(j) = forms(i).Caption And lstFormSelect.Selected(j) = True Then
- If forms(i).Tag = "College" Then
- TestYears = Val(forms(i).txtColAge) - Val(forms(i).txtAge) + Val(forms(i).txtColYears) - 1
- ElseIf forms(i).Tag = "General" Then
- TestYears = Val(forms(i).txtGenPer)
- End If
- If TestYears > GPeriods Then
- GPeriods = TestYears
- End If
- ' Added to delineate graph titles on frmGraph.Caption
- If j = 0 Then
- GenGraph(GraForm).Caption = "<" + lstFormSelect.List(j) + ">"
- Else
- GenGraph(GraForm).Caption = GenGraph(GraForm).Caption + " " + "<" + lstFormSelect.List(j) + ">"
- End If
- End If
- Next j
- Next i
-
- ' Run routine to add up each years values
- ArrayCalc GPeriods
-
- ' Determine the maximum value
- For i = 1 To GPeriods
- If CumAmtSavedArray(i) + CumIntArray(i) > GGoal Then GGoal = CumAmtSavedArray(i) + CumIntArray(i)
- Next i
-
- ' Determine Maximum Scale
- intMaxScale = (Int((GGoal - 1) / 1000) + 1) * 1000
-
- ' Put the graph year labels on the form
- For i = 0 To GPeriods - 1
- If i <> 0 Then
- Load GenGraph(GraForm).lblPerNo(i)
- GenGraph(GraForm).lblPerNo(i).Left = GenGraph(GraForm).lblPerNo(i - 1).Left + GenGraph(GraForm).lblPerNo(i - 1).Width
- End If
- GenGraph(GraForm).lblPerNo(i).Width = 7000 / GPeriods
- GenGraph(GraForm).lblPerNo(i).Caption = i + 1
- GenGraph(GraForm).lblPerNo(i).Enabled = True
- GenGraph(GraForm).lblPerNo(i).Visible = True
- Next i
-
- ' Put the dollar labels on the form
- For i = 0 To 9
- If i <> 0 Then
- Load GenGraph(GraForm).Line3(i)
- Load GenGraph(GraForm).Label1(i)
- GenGraph(GraForm).Line3(i).Y1 = GenGraph(GraForm).Line3(i - 1).Y1 - 400
- GenGraph(GraForm).Line3(i).Y2 = GenGraph(GraForm).Line3(i - 1).Y1 - 400
- GenGraph(GraForm).Label1(i).Top = GenGraph(GraForm).Label1(i - 1).Top - 400
- End If
- GenGraph(GraForm).Line3(i).Visible = True
- GenGraph(GraForm).Label1(i).Caption = Format$(intMaxScale / 10 * (i + 1), "$###,###")
- GenGraph(GraForm).Label1(i).Enabled = True
- GenGraph(GraForm).Label1(i).Visible = True
- Next
-
- CumAmtSavedArrayTotal = 0
- CumIntArrayTotal = 0
- For i = 0 To (GPeriods - 1) * 2 Step 2
-
- ' Create Graph bar for amount saved
- If i <> 0 Then Load GenGraph(GraForm).GraphBox(i)
- GenGraph(GraForm).GraphBox(i).Height = CumAmtSavedArray(i / 2 + 1) * 4000 / GGoal
- CumAmtSavedArrayTotal = CumAmtSavedArrayTotal + CumAmtSavedArray(i / 2 + 1)
- GenGraph(GraForm).GraphBox(i).Top = 4440 - GenGraph(GraForm).GraphBox(i).Height
- GenGraph(GraForm).GraphBox(i).Width = 7000 / GPeriods - 30
- If i <> 0 Then GenGraph(GraForm).GraphBox(i).Left = GenGraph(GraForm).GraphBox(i - 2).Left + GenGraph(GraForm).GraphBox(i).Width + 30
- GenGraph(GraForm).GraphBox(i).Visible = True
-
- ' Create Graph bar for interest amount
- If CumIntArray(i / 2 + 1) * 4000 / GGoal >= 1 Then
- Load GenGraph(GraForm).GraphBox(i + 1)
- GenGraph(GraForm).GraphBox(i + 1).Height = CumIntArray(i / 2 + 1) * 4000 / GGoal
- CumIntArrayTotal = CumIntArrayTotal + CumIntArray(i / 2 + 1)
- GenGraph(GraForm).GraphBox(i + 1).Top = GenGraph(GraForm).GraphBox(i).Top - GenGraph(GraForm).GraphBox(i + 1).Height
- GenGraph(GraForm).GraphBox(i + 1).Width = 7000 / GPeriods - 30
- GenGraph(GraForm).GraphBox(i + 1).Left = GenGraph(GraForm).GraphBox(i).Left
- GenGraph(GraForm).GraphBox(i + 1).BackColor = QBColor(14)
- GenGraph(GraForm).GraphBox(i + 1).Visible = True
- End If
- Next i
-
- ' Assign values on status bar
- GenGraph(GraForm).lblCumTotal = Format$(CumGrTotal, " $###,###,###")
- GenGraph(GraForm).lblCumAmtSaved = Format$(CumGrAmtSaved, " $###,###,###")
- GenGraph(GraForm).lblCumInt = Format$(CumGrIntAmt, " $###,###,###")
-
- GenGraph(GraForm).Show
-
- GraForm = GraForm + 1
- Else
- 'Combined grid routine
-
- ' Open new instance of frmGrid
- Set ComGrid(GriForm) = New frmGrid
-
- ComGrid(GriForm).Caption = ""
- GPeriods = 0
- On Error Resume Next
- Err = 0
-
- 'Iterate through all forms
- For i = 0 To forms.Count - 1
- 'Iterate through all listed forms
- For j = 0 To lstFormSelect.ListCount - 1
- 'Check to see if list selection is selected and find form
- If lstFormSelect.List(j) = forms(i).Caption And lstFormSelect.Selected(j) = True Then
- If forms(i).Tag = "College" Then
- TestYears = Val(forms(i).txtColAge) - Val(forms(i).txtAge) + Val(forms(i).txtColYears) - 1
- ElseIf forms(i).Tag = "General" Then
- TestYears = Val(forms(i).txtGenPer)
- End If
- If TestYears > GPeriods Then
- GPeriods = TestYears
- End If
- ' Added to delineate graph titles on frmGraph.Caption
- If j = 0 Then
- ComGrid(GriForm).Caption = "<" + lstFormSelect.List(j) + ">"
- Else
- ComGrid(GriForm).Caption = ComGrid(GriForm).Caption + " " + "<" + lstFormSelect.List(j) + ">"
- End If
- End If
- Next j
- Next i
-
- ' Set up grid
- If GPeriods > 0 Then
- ComGrid(GriForm).Grid1.Rows = GPeriods + 1
- Else
- ComGrid(GriForm).Grid1.Rows = 2
- End If
- ComGrid(GriForm).Grid1.Cols = 6: ComGrid(GriForm).Grid1.FixedCols = 0
- ComGrid(GriForm).Grid1.ColWidth(0) = 600
- ComGrid(GriForm).Grid1.RowHeight(0) = 700
- ComGrid(GriForm).Grid1.ColAlignment(1) = 2
- For i = 1 To 5
- ComGrid(GriForm).Grid1.ColWidth(i) = 1350
- ComGrid(GriForm).Grid1.ColAlignment(i) = 1
- Next i
- ComGrid(GriForm).Grid1.Row = 0: ComGrid(GriForm).Grid1.Col = 0: ComGrid(GriForm).Grid1.Text = "Years"
- ComGrid(GriForm).Grid1.Col = 1: ComGrid(GriForm).Grid1.Text = "Amount Saved This Period"
- ComGrid(GriForm).Grid1.Col = 2: ComGrid(GriForm).Grid1.Text = "Accumulated Amount Saved"
- ComGrid(GriForm).Grid1.Col = 3: ComGrid(GriForm).Grid1.Text = "Interest Earned"
- ComGrid(GriForm).Grid1.Col = 4: ComGrid(GriForm).Grid1.Text = "Accumulated Interest"
- ComGrid(GriForm).Grid1.Col = 5: ComGrid(GriForm).Grid1.Text = "Total Accumulated Savings"
-
- ' Run routine to add up each years values
- ArrayCalc GPeriods
-
- ' Start assigning values to the grid
- For i = 1 To GPeriods
- ComGrid(GriForm).Grid1.Row = i
- ComGrid(GriForm).Grid1.Col = 0: ComGrid(GriForm).Grid1.Text = Str$(i)
- ComGrid(GriForm).Grid1.Col = 1: ComGrid(GriForm).Grid1.Text = Format$(AmtToSaveArray(i), "$###,##0.00")
- ComGrid(GriForm).Grid1.Col = 2: ComGrid(GriForm).Grid1.Text = Format$(CumAmtSavedArray(i), "$###,##0.00")
- ComGrid(GriForm).Grid1.Col = 3: ComGrid(GriForm).Grid1.Text = Format$(IntAmtArray(i), "$###,##0.00")
- ComGrid(GriForm).Grid1.Col = 4: ComGrid(GriForm).Grid1.Text = Format$(CumIntArray(i), "$###,##0.00")
- ComGrid(GriForm).Grid1.Col = 5: ComGrid(GriForm).Grid1.Text = Format$(CumAmtSavedArray(i) + CumIntArray(i), "$###,##0.00")
- Next i
- ComGrid(GriForm).Grid1.Col = 1
- ComGrid(GriForm).Grid1.Row = 1
-
- ' Update values to the status bar
- ComGrid(GriForm).lblCumTotal = Format$(CumGrTotal, " $###,###,###")
- ComGrid(GriForm).lblCumAmtSaved = Format$(CumGrAmtSaved, " $###,###,###")
- ComGrid(GriForm).lblCumInt = Format$(CumGrIntAmt, " $###,###,###")
-
- ComGrid(GriForm).Show
- End If
- screen.MousePointer = 0
- Unload frmFormSelect
- End Sub
- Sub lstFormSelect_Click ()
- DoEnable = False
- For i = 0 To lstFormSelect.ListCount - 1
- If lstFormSelect.Selected(i) = True Then
- DoEnable = True
- End If
- Next
- If DoEnable Then cmdGo.Enabled = True Else cmdGo.Enabled = False
- End Sub
-