home *** CD-ROM | disk | FTP | other *** search
- 'Declare Global Constants used throughout the application
- Global Const intTotalforms = 30
- Global Col(intTotalforms) As frmCollege
- Global Gen(intTotalforms) As frmGeneral
- Global ComGrid(intTotalforms) As frmGrid
- Global GenGraph(intTotalforms) As frmGraph
- Global ColForm As Integer
- Global GenForm As Integer
- Global GriForm As Integer
- Global GraForm As Integer
- Global TotalColCost As Variant
- Global TotalDiscColCost As Variant
- Global FormNo As Variant
- Global NeedToSave As Variant
- Global GoalType As String
- Global FormNumb As Variant
- Global AmtToSaveArray(100) As Variant
- Global CumAmtSavedArray(100) As Variant
- Global IntAmtArray(100) As Variant
- Global CumIntArray(100) As Variant
- Global SelectCancel As Integer
-
- ' Arrange Method for MDI Forms
- Global Const CASCADE = 0
- Global Const ARRANGE_ICONS = 3
-
- ' Show parameters
- Global Const MODAL = 1
- Global Const MODELESS = 0
-
- ' Help engine declarations.
- Declare Function WinHelp Lib "User" (ByVal hWnd As Integer, ByVal lpHelpFile As String, ByVal wCommand As Integer, dwData As Any) As Integer
-
- ' Commands to pass WinHelp()
- Global Const HELP_CONTEXT = &H1 ' Display topic identified by number in Data
- Global Const HELP_QUIT = &H2 ' Terminate help
- Global Const HELP_INDEX = &H3 ' Display index
- Global Const HELP_HELPONHELP = &H4 ' Display help on using help
- Global Const HELP_SETINDEX = &H5 ' Set an alternate Index for help file with more than one index
- Global Const HELP_KEY = &H101 ' Display topic for keyword in Data
- Global Const HELP_MULTIKEY = &H201 ' Lookup keyword in alternate table and display topic
-
-
- ' Memory management functions for determining system information
- ' displayed in the About Dialog
-
- ' Returns the current system configurations flags
- Declare Function GetWinFlags Lib "kernel" () As Long
-
- ' Returns the number of free bytes in the global heap
- Declare Function GetFreeSpace Lib "kernel" (ByVal flag%) As Long
-
- ' System configuration flags
- Global Const WF_CPU286 = &H2&
- Global Const WF_CPU386 = &H4&
- Global Const WF_CPU486 = &H8&
- Global Const WF_STANDARD = &H10&
- Global Const WF_ENHANCED = &H20&
- Global Const WF_80x87 = &H400&
-
-
- Sub ButtonsHide ()
- ' Hide the graph and grid buttons on the toolbar
- If frmMDI.Line25.Visible = True Then
- frmMDI.Line25.Visible = False
- frmMDI.Line26.Visible = False
- frmMDI.Line27.Visible = False
- frmMDI.Line28.Visible = False
- frmMDI.Line29.Visible = False
- frmMDI.Line30.Visible = False
- frmMDI.Line31.Visible = False
- frmMDI.Line32.Visible = False
- frmMDI.Line33.Visible = False
- frmMDI.Line34.Visible = False
- frmMDI.Line35.Visible = False
- frmMDI.Line36.Visible = False
- frmMDI.Line37.Visible = False
- frmMDI.Line38.Visible = False
- frmMDI.Line39.Visible = False
- frmMDI.Line40.Visible = False
- frmMDI.imgGraph.Visible = False
- frmMDI.imgComGraph.Visible = False
- frmMDI.imgGrid.Visible = False
- frmMDI.imgComGrid.Visible = False
- frmMDI.Shape6.Visible = False
- frmMDI.Shape7.Visible = False
- frmMDI.Shape8.Visible = False
- frmMDI.Shape9.Visible = False
- End If
- End Sub
-
- Sub ButtonsVisible ()
- ' Make the graph and grid buttons visible on the toolbar
- If frmMDI.Line25.Visible = False Then
- frmMDI.Line25.Visible = True
- frmMDI.Line26.Visible = True
- frmMDI.Line27.Visible = True
- frmMDI.Line28.Visible = True
- frmMDI.Line29.Visible = True
- frmMDI.Line30.Visible = True
- frmMDI.Line31.Visible = True
- frmMDI.Line32.Visible = True
- frmMDI.Line33.Visible = True
- frmMDI.Line34.Visible = True
- frmMDI.Line35.Visible = True
- frmMDI.Line36.Visible = True
- frmMDI.Line37.Visible = True
- frmMDI.Line38.Visible = True
- frmMDI.Line39.Visible = True
- frmMDI.Line40.Visible = True
- frmMDI.imgGraph.Visible = True
- frmMDI.imgComGraph.Visible = True
- frmMDI.imgGrid.Visible = True
- frmMDI.imgComGrid.Visible = True
- frmMDI.Shape6.Visible = True
- frmMDI.Shape7.Visible = True
- frmMDI.Shape8.Visible = True
- frmMDI.Shape9.Visible = True
- End If
- End Sub
-
- Sub CenterForm (frmParent As MDIForm, frmChild As Form)
- ' This procedure centers a child form over a parent form.
- ' Calling this routine loads the dialog. Use the Show method
- ' to display the dialog after calling this routine ( ie MyFrm.Show 1)
-
- ' get left offset
- l = frmParent.Left + ((frmParent.Width - frmChild.Width) / 2)
- If (l + frmChild.Width > Screen.Width) Then
- l = Screen.Width = frmChild.Width
- End If
-
- ' get top offset
- t = frmParent.Top + ((frmParent.Height - frmChild.Height) / 2)
- If (t + frmChild.Height > Screen.Height) Then
- t = Screen.Height - frmChild.Height
- End If
-
- ' center the child formfv
- frmChild.Move l, t
-
- End Sub
-
- Sub CheckToSave ()
- ' This routine is run if changes are made and you are quitting,
- ' loading another plan, or starting a new plan
- SelectCancel = False
- AskCheck = False
- For i = 0 To forms.Count - 1
- If forms(i).Tag = "College" Or forms(i).Tag = "General" Then
- AskCheck = True
- End If
- Next
- If AskCheck Then
- Dim Msg, NL
- Dim Response As Integer
- NL = Chr$(10) & Chr$(13)
- Msg = "The information in this savings plan has been changed."
- Msg = Msg & NL
- Msg = Msg & "Do you want to save the changes?"
- Response = MsgBox(Msg, 51)
- Select Case Response
- Case 2 'User selects Cancel, cancel the unload
- SelectCancel = True
- Cancel = True
- Case 6 'User select Yes, save the savings plan
- SelectCancel = False
- SavePlan 'Invoke the Save procedure
- Case 7 'User selects No, Ok to unload
- SelectCancel = False
- Cancel = False
- End Select
- End If
- End Sub
-
- Function colpmt (c, ci, IntRate, n, ny, S, PerType)
- On Error GoTo FixColPmtError
- ' This routine calculates the amount to save for college
- ' c=Current College annual expense
- ' ci=Annual percent increase in College expense
- ' intrate=rate of return expected on investments
- ' n=number of years till college
- ' ny=number of years in college
- ' s=amount already saved toward college
- ' PerType = Yearly (1) or Monthly (2)
- TotalColCost = 0: TotalDiscColCost = 0
- For i = 0 To ny - 1
- ColCost = c * (1 + ci) ^ (n + i)'Cost at that year
- TotalColCost = TotalColCost + ColCost
- DiscColCost = ColCost * (1 + IntRate) ^ -(n + i) 'Present Value of that year
- TotalDiscColCost = TotalDiscColCost + DiscColCost
- Next i
- If PerType <> 1 Then
- IntRate = IntRate / 12: n = n * 12 - 11: ny = ny * 12
- End If
- colpmt = (TotalDiscColCost - S) * (IntRate / (1 - (1 + IntRate) ^ -(n + ny - 1)))
- Exit Function
-
- FixColPmtError:
- If Err Then
- MsgBox Error$
- Exit Function
- End If
- End Function
-
- Sub FOpenProc ()
- 'Open form to open a savings plan
- frmForm.Caption = "Open"
- CenterForm frmMDI, frmForm
- frmForm.Show MODAL
- End Sub
-
- Sub FormSelectProc (ButtonType As String)
- ' Select which forms are to be graphed or gridded using combined method
- ' Set the form's caption
- If ButtonType = "Graph" Then
- frmFormSelect.Caption = "Graph which goals?"
- frmFormSelect.cmdGo.Caption = "Graph"
- ElseIf ButtonType = "Grid" Then
- frmFormSelect.cmdGo.Caption = "Grid"
- frmFormSelect.Caption = "Grid which goals?"
- End If
- ' Center the FileOpen/Save form over the MDI form
- CenterForm frmMDI, frmFormSelect
- ' Show the FileOpen/Save form
- On Error Resume Next
- Err = 0: j = 0: ReDim FormSelFormNumb(10) As Integer: ReDim FormSelGoalType(10) As String
- For i = 0 To forms.Count - 1
- If forms(i).Tag = "College" Or forms(i).Tag = "General" Then
- frmFormSelect.lstFormSelect.AddItem forms(i).Caption
- End If
- Next
- frmFormSelect.Show MODAL
- End Sub
-
- Sub GraphIt (TagStr As String, GName, GIntRate, GPer, GSaved, AmtToSave, GGoal, GCAge, GAge, Divider, GCAnnCost, GColInc, GType)
- On Error GoTo FixGraphIt
- 'Routine to graph single goal
- 'Tagstr = is the value of the Tag property of the goal form
- 'GName = is the Goal Name
- 'GIntRate = Rate of Return of investment per period
- 'GPer = number of periods
- 'GSaved = Amount already saved
- 'AmtToSave = Amount to save per period
- 'GGoal = Total goal to be saved
- 'GCAge = Age at beginning of College
- 'GAge = Current age
- 'Divider = how much to divide the interest rate by for 8%=0.08
- 'GCAnnCost= Current annual cost of college
- 'GColInc = Annual Cost of College
- 'GType = 1 for General, 2 for College goal
- 'display hourglass for pointer
- Screen.MousePointer = 11
-
- FormNo = Val(Mid$(TagStr, 8))
-
- 'Open new instance of frmGraph
- Set GenGraph(FormNo) = New frmGraph
- GenGraph(FormNo).Caption = GName + " - Graph"
-
- 'Determine maximum scale amount
- intMaxScale = (Int((GGoal - 1) / 1000) + 1) * 1000
-
- 'Place the year labels on the form
- For i = 0 To GPer - 1
- If i <> 0 Then
- Load GenGraph(FormNo).lblPerNo(i)
- GenGraph(FormNo).lblPerNo(i).Left = GenGraph(FormNo).lblPerNo(i - 1).Left + GenGraph(FormNo).lblPerNo(i - 1).Width
- End If
- GenGraph(FormNo).lblPerNo(i).Width = 7000 / GPer
- GenGraph(FormNo).lblPerNo(i).Caption = i + 1
- GenGraph(FormNo).lblPerNo(i).Enabled = True
- GenGraph(FormNo).lblPerNo(i).Visible = True
- Next i
-
- 'Place the dollar amount labels on the form
- For i = 0 To 9
- If i <> 0 Then
- Load GenGraph(FormNo).Line3(i)
- Load GenGraph(FormNo).Label1(i)
- GenGraph(FormNo).Line3(i).Y1 = GenGraph(FormNo).Line3(i - 1).Y1 - 400
- GenGraph(FormNo).Line3(i).Y2 = GenGraph(FormNo).Line3(i - 1).Y1 - 400
- GenGraph(FormNo).Label1(i).Top = GenGraph(FormNo).Label1(i - 1).Top - 400
- End If
- GenGraph(FormNo).Line3(i).Visible = True
- GenGraph(FormNo).Label1(i).Caption = Format$(intMaxScale / 10 * (i + 1), "$###,###")
- GenGraph(FormNo).Label1(i).Enabled = True
- GenGraph(FormNo).Label1(i).Visible = True
- Next
-
- 'Place the principal and interest bars on form
- CumInt = 0: IntAmt = 0: CumAmtSaved = GSaved: CumTotal = GSaved
- For i = 0 To (GPer - 1) * 2 Step 2
-
- 'New GraphBox for cumulative amount saved
- If i <> 0 Then Load GenGraph(FormNo).GraphBox(i)
-
- CumAmtSaved = CumAmtSaved + AmtToSave
- IntAmt = CumTotal * GIntRate
- CumInt = CumInt + IntAmt
- If (CumAmtSaved * 4000 / GGoal) < 1 Then
- GenGraph(FormNo).GraphBox(i).Height = 1
- Else
- GenGraph(FormNo).GraphBox(i).Height = CumAmtSaved * 4000 / GGoal
- End If
- GenGraph(FormNo).GraphBox(i).Top = 4440 - GenGraph(FormNo).GraphBox(i).Height
- GenGraph(FormNo).GraphBox(i).Width = 7000 / GPer - 30
- If i <> 0 Then GenGraph(FormNo).GraphBox(i).Left = GenGraph(FormNo).GraphBox(i - 2).Left + GenGraph(FormNo).GraphBox(i).Width + 30
- GenGraph(FormNo).GraphBox(i).Visible = True
- If CumInt * 4000 / GGoal >= 1 Then
-
- 'New GraphBox for cumulative interest
- Load GenGraph(FormNo).GraphBox(i + 1)
- GenGraph(FormNo).GraphBox(i + 1).Height = CumInt * 4000 / GGoal
-
- GenGraph(FormNo).GraphBox(i + 1).Top = GenGraph(FormNo).GraphBox(i).Top - GenGraph(FormNo).GraphBox(i + 1).Height
- GenGraph(FormNo).GraphBox(i + 1).Width = 7000 / GPer - 30
- GenGraph(FormNo).GraphBox(i + 1).Left = GenGraph(FormNo).GraphBox(i).Left
- GenGraph(FormNo).GraphBox(i + 1).BackColor = QBColor(14)
- GenGraph(FormNo).GraphBox(i + 1).Visible = True
- End If
- CumTotal = CumTotal + AmtToSave + IntAmt
-
- ' Check for start of each year of College and
- ' subtract out cost of College
- If i >= (Val(GCAge) - Val(GAge)) * 2 - 2 And GType = 2 Then
- CumTotal = CumTotal - GCAnnCost * (1 + GColInc / 100) ^ ((i + 2) / 2)
- End If
-
- If i = GPer - 1 And GType = 1 Then
- CumTotal = CumTotal - GPrice
- End If
- Next i
-
- 'Update status bar
- GenGraph(FormNo).lblCumAmtSaved = Format$(CumAmtSaved, " $##,###,###,###")
- GenGraph(FormNo).lblCumInt = Format$(CumInt, " $##,###,###,###")
- If TagStr = "College" Then
- CumTotal = CumInt + CumAmtSaved
- End If
- GenGraph(FormNo).lblCumTotal = Format$(CumTotal, " $###,###,###,###")
-
- GenGraph(FormNo).Show
-
- 'Change mouse pointer back to point
- Screen.MousePointer = 0
- Exit Sub
-
- FixGraphIt:
- If Err Then
- MsgBox Error$
- Screen.MousePointer = 0
- Exit Sub
- End If
- End Sub
-
- Sub GridSetup (GType, GName, GPeriods, GPrice, GiRate, GSaved, GCAge, GAge, GCYears, GCAnnCost, GColInc)
- On Error GoTo FixGridSetup:
- 'Routine to grid a single goal
-
- 'set status bar values back to zero
- CumGrAmtSaved = 0
- CumGrIntAmt = 0
- CumGrTotal = 0
-
- 'display hourglass for pointer
- Screen.MousePointer = 11
-
- 'Open new instance of frmGrid form
- Set ComGrid(GriForm) = New frmGrid
- ComGrid(GriForm).Tag = GriForm
-
- ComGrid(GriForm).Caption = GName + " - Grid"
-
- 'Set up the grids rows and columns
- 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"
-
- 'Determine the amount to save each year
- If GType = 2 Then
- AmtToSave = colpmt(GCAnnCost, GColInc / 100, GiRate / 100, GCAge - GAge, GCYears, GSaved, 1)
- Else
- AmtToSave = pmt(GPrice, GiRate / 100, GPeriods, GSaved)
- End If
-
- 'Fill in the grid
- CumInt = 0: IntAmt = 0: CumAmtSaved = 0
- CumAmtSaved = GSaved: CumTotal = GSaved: CumGrAmtSaved = GSaved
- 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$(AmtToSave, "$###,##0.00")
- ComGrid(GriForm).Grid1.Col = 2: CumAmtSaved = CumAmtSaved + AmtToSave: ComGrid(GriForm).Grid1.Text = Format$(CumAmtSaved, "$###,##0.00")
- ComGrid(GriForm).Grid1.Col = 3: IntAmt = (CumTotal) * GiRate / 100: ComGrid(GriForm).Grid1.Text = Format$(IntAmt, "$###,##0.00")
- ComGrid(GriForm).Grid1.Col = 4: CumInt = CumInt + IntAmt: ComGrid(GriForm).Grid1.Text = Format$(CumInt, "$###,##0.00")
- ' Check for start of each year of College
- If i >= (Val(GCAge) - Val(GAge)) And i - Int(i) = 0 And GType = 2 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
- ComGrid(GriForm).Grid1.Col = 5: ComGrid(GriForm).Grid1.Text = Format$(CumAmtSaved + CumInt, "$###,##0.00")
-
- 'Save cumulative amounts for status bar
- CumGrAmtSaved = CumGrAmtSaved + AmtToSave
- CumGrIntAmt = CumGrIntAmt + IntAmt
- CumGrTotal = CumGrAmtSaved + CumGrIntAmt
- Next i
-
- 'Place currency on the first row and column
- ComGrid(GriForm).Grid1.Col = 1
- ComGrid(GriForm).Grid1.Row = 1
-
- 'Update the status bar
- ComGrid(GriForm).lblCumTotal = Format$(CumGrTotal, " $###,###,###")
- ComGrid(GriForm).lblCumAmtSaved = Format$(CumGrAmtSaved, " $###,###,###")
- ComGrid(GriForm).lblCumInt = Format$(CumGrIntAmt, " $###,###,###")
-
- ComGrid(GriForm).Show
-
- 'Change mouse pointer back to point
- Screen.MousePointer = 0
- Exit Sub
- FixGridSetup:
- If Err Then
- MsgBox Error$
- Screen.MousePointer = 0
- Exit Sub
- End If
- End Sub
-
- Sub NewCGoal ()
- On Error GoTo FixCGoalError
- 'Open a new instance of the college form
- If ColForm <= intTotalforms Then
- Set Col(ColForm) = New frmCollege
- Col(ColForm).Show
- End If
- Exit Sub
- FixCGoalError:
- If Err Then
- MsgBox Error$
- Exit Sub
- End If
-
- End Sub
-
- Sub NewGGoal ()
- On Error GoTo FixGGoalError:
- 'Open a new instance of the general form
- If GenForm <= intTotalforms Then
- Set Gen(GenForm) = New frmGeneral
- Gen(GenForm).Show
- End If
- Exit Sub
-
- FixGGoalError:
- If Err Then
- MsgBox Error$
- Exit Sub
- End If
- End Sub
-
- Sub NewSavePlan ()
- Screen.MousePointer = 11
- ' Since MDI forms don't have an MDIChild property,
- ' the If statement below will cause an error when
- ' the MDI form is evaluated.
- On Error Resume Next
- Err = 0
- ' Iterate through all the goal forms
- For i = 1 To forms.Count - 1
- ' find all forms that have MDIChild = True
- x = forms(1).MDIChild
- If x Then
- Unload forms(1)
- End If
- Next
- NeedToSave = False
- ' reset the mousepointer
- Screen.MousePointer = 0
- ' set the MDIForm's caption
- frmMDI.Caption = "Savings - Untitled"
- ColForm = 0: GenForm = 0: GriForm = 0: GraForm = 0
- End Sub
-
- Sub OpenFile (FileName)
- On Error Resume Next
- ' open the selected file
- Open FileName For Input As #1
- If Err Then
- MsgBox Error$
- Exit Sub
- End If
- ' change mousepointer to an hourglass
- Screen.MousePointer = 11
-
- ' copy the file's contents into a variable
- ColForm = 0: GenForm = 0
- Do Until EOF(1)
- Line Input #1, GetLine
- TypeOfLine = Mid$(GetLine, 1, InStr(1, GetLine, ",") - 1)
- GetLine = Mid$(GetLine, InStr(1, GetLine, ",") + 1, Len(GetLine))
- If TypeOfLine = "College" Then
- Set Col(ColForm) = New frmCollege
- FormNo = ColForm
- Col(FormNo).txtColName.Text = Mid$(GetLine, 1, InStr(1, GetLine, ",") - 1)
- GetLine = Mid$(GetLine, InStr(1, GetLine, ",") + 1, Len(GetLine))
- Col(FormNo).txtAge.Text = Mid$(GetLine, 1, InStr(1, GetLine, ",") - 1)
- GetLine = Mid$(GetLine, InStr(1, GetLine, ",") + 1, Len(GetLine))
- Col(FormNo).txtColAge = Mid$(GetLine, 1, InStr(1, GetLine, ",") - 1)
- GetLine = Mid$(GetLine, InStr(1, GetLine, ",") + 1, Len(GetLine))
- Col(FormNo).txtColAnnCost = Mid$(GetLine, 1, InStr(1, GetLine, ",") - 1)
- GetLine = Mid$(GetLine, InStr(1, GetLine, ",") + 1, Len(GetLine))
- Col(FormNo).txtColIncrease = Mid$(GetLine, 1, InStr(1, GetLine, ",") - 1)
- GetLine = Mid$(GetLine, InStr(1, GetLine, ",") + 1, Len(GetLine))
- Col(FormNo).txtColIntRate = Mid$(GetLine, 1, InStr(1, GetLine, ",") - 1)
- GetLine = Mid$(GetLine, InStr(1, GetLine, ",") + 1, Len(GetLine))
- Col(FormNo).txtColSaved = Mid$(GetLine, 1, InStr(1, GetLine, ",") - 1)
- GetLine = Mid$(GetLine, InStr(1, GetLine, ",") + 1, Len(GetLine))
- Col(FormNo).txtColYears = GetLine
- Col(FormNo).Show
- ElseIf TypeOfLine = "General" Then
- Set Gen(GenForm) = New frmGeneral
- FormNo = GenForm
- Gen(FormNo).txtGenName = Mid$(GetLine, 1, InStr(1, GetLine, ",") - 1)
- GetLine = Mid$(GetLine, InStr(1, GetLine, ",") + 1, Len(GetLine))
- Gen(FormNo).txtGenPer = Mid$(GetLine, 1, InStr(1, GetLine, ",") - 1)
- GetLine = Mid$(GetLine, InStr(1, GetLine, ",") + 1, Len(GetLine))
- Gen(FormNo).txtGenIntRate = Mid$(GetLine, 1, InStr(1, GetLine, ",") - 1)
- GetLine = Mid$(GetLine, InStr(1, GetLine, ",") + 1, Len(GetLine))
- Gen(FormNo).txtGenPrice = Mid$(GetLine, 1, InStr(1, GetLine, ",") - 1)
- GetLine = Mid$(GetLine, InStr(1, GetLine, ",") + 1, Len(GetLine))
- Gen(FormNo).txtGenSaved = GetLine
- Gen(FormNo).Show
- Else
- Screen.MousePointer = 0
- MsgBox "Incorrect file format"
- Close #1
- Exit Sub
- End If
- TextIn = TextIn + GetLine + NL
- Loop
- Close #1
-
- ' change form's caption and display new text
- frmMDI.Caption = "Savings - " + UCase$(FileName)
-
- ' unload the Open dialog
- Unload frmForm
-
- ' reset mouse pointer
- Screen.MousePointer = 0
- NeedToSave = False
- End Sub
-
- Sub OptionsToolbarProc (FormName As Form)
- 'Toggle the toolbar on and off
- FormName.mnuToolbar.Checked = Not FormName.mnuToolbar.Checked
- If FormName.mnuToolbar.Checked Then
- frmMDI.picToolbar.Visible = True
- Else
- frmMDI.picToolbar.Visible = False
- End If
- End Sub
-
- Function pmt (P, i, n, S)
- On Error GoTo FixpmtError:
- ' Returns the payment amount on a general goal
- ' p=amount to accumlate with interest
- ' i=expected rate of return on investment per period
- ' n=number of periods
- ' s=amount already saved toward goal
- pmt = (P - S * (1 + i) ^ n) * i / ((1 + i) ^ n - 1)
- Exit Function
- FixpmtError:
- If Err Then
- MsgBox Error$
- Exit Function
- End If
-
- End Function
-
- Sub SaveAsPlan ()
- ' Set the form's caption
- frmForm.Caption = "Save As"
- ' Center the FileOpen/Save form over the MDI form
- CenterForm frmMDI, frmForm
- ' Show the FileOpen/Save form
- frmForm.Show MODAL
- End Sub
-
- Sub SaveFileAs (FileName)
- On Error Resume Next
-
- If InStr(FileName, ".") = 0 Then
- FileName = FileName + ".sav"
- End If
-
- ' check if user wants to overwrite existing file
- If Mid$(frmMDI.Caption, 11) <> UCase$(FileName) Then
- If Dir(FileName) = UCase$(FileName) Then
- n = MsgBox("Overwrite contents of file '" + FileName + "' ?", 36)
- If n = 7 Then
- Exit Sub
- End If
- End If
- End If
-
- ' open the file
- Open FileName For Output As #1
-
- If Err Then
- MsgBox Error$
- Exit Sub
- End If
-
- ' display hourglass
- Screen.MousePointer = 11
- ' Since MDI forms don't have an MDIChild property,
- ' the If statement below will cause an error when
- ' the MDI form is evaluated.
-
- Err = 0
- ' Iterate through all the goal forms
- For i = 0 To forms.Count - 1
- ' find all forms that have MDIChild = True
- x = forms(i).MDIChild
- If x Then
- If Mid$(forms(i).Tag, 1, 3) = "Col" Then
- Print #1, "College,";
- Print #1, forms(i).txtColName + ",";
- Print #1, forms(i).txtAge + ",";
- Print #1, forms(i).txtColAge + ",";
- Print #1, forms(i).txtColAnnCost + ",";
- Print #1, forms(i).txtColIncrease + ",";
- Print #1, forms(i).txtColIntRate + ",";
- Print #1, forms(i).txtColSaved + ",";
- Print #1, forms(i).txtColYears
- ElseIf Mid$(forms(i).Tag, 1, 3) = "Gen" Then
- Print #1, "General,";
- Print #1, forms(i).txtGenName + ",";
- Print #1, forms(i).txtGenPer + ",";
- Print #1, forms(i).txtGenIntRate + ",";
- Print #1, forms(i).txtGenPrice + ",";
- Print #1, forms(i).txtGenSaved
- End If
- End If
- Next i
- Close #1
- ' close the Save As dialog
- Unload frmForm
- ' reset the mousepointer
- Screen.MousePointer = 0
- ' set the MDIForm's caption
- frmMDI.Caption = "Savings - " + UCase$(FileName)
- NeedToSave = False
- End Sub
-
- Sub SavePlan ()
- If frmMDI.Caption = "Savings - Untitled" Then
- ' The file hasn't been saved yet, call the
- ' Save File As procedure which prompts for a file name
- SaveAsPlan
- Else
- ' The caption contains the name of the open file
- FileName = Mid$(frmMDI.Caption, 11)
- SaveFileAs FileName
- End If
- End Sub
-
-