' Student: Pat Moss ' Instructor: Greg Simpson ' CIS259, Sect. 5844, VB.NET II ' January 24, 2006 Tuesday 5:40 pm ' Chapter 02, Project 05, p. 122-123 ' This form is: frmMain.vb Rev. 01b Main screen ' Software Specification: ' Design an Amortization Schedule, including a Startup ' Sub Main procedure, a Splash screen, a User Input Screen, ' the Amortization Schedule screen, and Menu controls. Option Strict On Option Explicit On Public Class frmMain Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents mmuMain As System.Windows.Forms.MainMenu Friend WithEvents mmuFile As System.Windows.Forms.MenuItem Friend WithEvents mmuFileExit As System.Windows.Forms.MenuItem Friend WithEvents mmuDisplay As System.Windows.Forms.MenuItem Friend WithEvents mmuDisplayAmort As System.Windows.Forms.MenuItem Friend WithEvents mmuHelp As System.Windows.Forms.MenuItem Friend WithEvents mmuHelpAbout As System.Windows.Forms.MenuItem Friend WithEvents tipGeneral As System.Windows.Forms.ToolTip Friend WithEvents txtBegPrin As System.Windows.Forms.TextBox Friend WithEvents txtAddPymt As System.Windows.Forms.TextBox Friend WithEvents txtPeriods As System.Windows.Forms.TextBox Friend WithEvents txtIntRate As System.Windows.Forms.TextBox Friend WithEvents lblBegPrin As System.Windows.Forms.Label Friend WithEvents lblAddPymt As System.Windows.Forms.Label Friend WithEvents lblPeriods As System.Windows.Forms.Label Friend WithEvents lblIntRate As System.Windows.Forms.Label Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container Me.mmuMain = New System.Windows.Forms.MainMenu Me.mmuFile = New System.Windows.Forms.MenuItem Me.mmuFileExit = New System.Windows.Forms.MenuItem Me.mmuDisplay = New System.Windows.Forms.MenuItem Me.mmuDisplayAmort = New System.Windows.Forms.MenuItem Me.mmuHelp = New System.Windows.Forms.MenuItem Me.mmuHelpAbout = New System.Windows.Forms.MenuItem Me.tipGeneral = New System.Windows.Forms.ToolTip(Me.components) Me.lblBegPrin = New System.Windows.Forms.Label Me.lblAddPymt = New System.Windows.Forms.Label Me.lblPeriods = New System.Windows.Forms.Label Me.lblIntRate = New System.Windows.Forms.Label Me.txtBegPrin = New System.Windows.Forms.TextBox Me.txtAddPymt = New System.Windows.Forms.TextBox Me.txtPeriods = New System.Windows.Forms.TextBox Me.txtIntRate = New System.Windows.Forms.TextBox Me.SuspendLayout() ' 'mmuMain ' Me.mmuMain.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mmuFile, Me.mmuDisplay, Me.mmuHelp}) ' 'mmuFile ' Me.mmuFile.Index = 0 Me.mmuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mmuFileExit}) Me.mmuFile.Text = "&File" ' 'mmuFileExit ' Me.mmuFileExit.Index = 0 Me.mmuFileExit.Text = "E&xit" ' 'mmuDisplay ' Me.mmuDisplay.Index = 1 Me.mmuDisplay.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mmuDisplayAmort}) Me.mmuDisplay.Text = "&Display" ' 'mmuDisplayAmort ' Me.mmuDisplayAmort.Index = 0 Me.mmuDisplayAmort.Text = "&Amortization" ' 'mmuHelp ' Me.mmuHelp.Index = 2 Me.mmuHelp.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mmuHelpAbout}) Me.mmuHelp.Text = "&Help" ' 'mmuHelpAbout ' Me.mmuHelpAbout.Index = 0 Me.mmuHelpAbout.Text = "A&bout" ' 'lblBegPrin ' Me.lblBegPrin.BackColor = System.Drawing.SystemColors.Control Me.lblBegPrin.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lblBegPrin.ImageAlign = System.Drawing.ContentAlignment.MiddleRight Me.lblBegPrin.Location = New System.Drawing.Point(8, 32) Me.lblBegPrin.Name = "lblBegPrin" Me.lblBegPrin.Size = New System.Drawing.Size(168, 23) Me.lblBegPrin.TabIndex = 0 Me.lblBegPrin.Text = "Initial Investment" Me.lblBegPrin.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'lblAddPymt ' Me.lblAddPymt.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lblAddPymt.ImageAlign = System.Drawing.ContentAlignment.MiddleRight Me.lblAddPymt.Location = New System.Drawing.Point(8, 64) Me.lblAddPymt.Name = "lblAddPymt" Me.lblAddPymt.Size = New System.Drawing.Size(168, 23) Me.lblAddPymt.TabIndex = 1 Me.lblAddPymt.Text = "Additional Payments" Me.lblAddPymt.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'lblPeriods ' Me.lblPeriods.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lblPeriods.ImageAlign = System.Drawing.ContentAlignment.MiddleRight Me.lblPeriods.Location = New System.Drawing.Point(8, 96) Me.lblPeriods.Name = "lblPeriods" Me.lblPeriods.Size = New System.Drawing.Size(168, 23) Me.lblPeriods.TabIndex = 2 Me.lblPeriods.Text = "Length of Investment" Me.lblPeriods.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'lblIntRate ' Me.lblIntRate.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lblIntRate.ImageAlign = System.Drawing.ContentAlignment.MiddleRight Me.lblIntRate.Location = New System.Drawing.Point(8, 128) Me.lblIntRate.Name = "lblIntRate" Me.lblIntRate.Size = New System.Drawing.Size(168, 23) Me.lblIntRate.TabIndex = 3 Me.lblIntRate.Text = "Interest Rate" Me.lblIntRate.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'txtBegPrin ' Me.txtBegPrin.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtBegPrin.Location = New System.Drawing.Point(192, 32) Me.txtBegPrin.Name = "txtBegPrin" Me.txtBegPrin.Size = New System.Drawing.Size(152, 26) Me.txtBegPrin.TabIndex = 4 Me.txtBegPrin.Text = "" ' 'txtAddPymt ' Me.txtAddPymt.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtAddPymt.Location = New System.Drawing.Point(192, 64) Me.txtAddPymt.Name = "txtAddPymt" Me.txtAddPymt.Size = New System.Drawing.Size(152, 26) Me.txtAddPymt.TabIndex = 5 Me.txtAddPymt.Text = "" ' 'txtPeriods ' Me.txtPeriods.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtPeriods.Location = New System.Drawing.Point(192, 96) Me.txtPeriods.Name = "txtPeriods" Me.txtPeriods.Size = New System.Drawing.Size(152, 26) Me.txtPeriods.TabIndex = 6 Me.txtPeriods.Text = "" ' 'txtIntRate ' Me.txtIntRate.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtIntRate.Location = New System.Drawing.Point(192, 128) Me.txtIntRate.Name = "txtIntRate" Me.txtIntRate.Size = New System.Drawing.Size(152, 26) Me.txtIntRate.TabIndex = 7 Me.txtIntRate.Text = "" ' 'frmMain ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(400, 185) Me.Controls.Add(Me.txtIntRate) Me.Controls.Add(Me.txtPeriods) Me.Controls.Add(Me.txtAddPymt) Me.Controls.Add(Me.txtBegPrin) Me.Controls.Add(Me.lblIntRate) Me.Controls.Add(Me.lblPeriods) Me.Controls.Add(Me.lblAddPymt) Me.Controls.Add(Me.lblBegPrin) Me.Menu = Me.mmuMain Me.Name = "frmMain" Me.ShowInTaskbar = False Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "Chap 2, Proj 5 Input Screen by Pat Moss" Me.ResumeLayout(False) End Sub #End Region ' Display an Amortization Schedule via form frmAmort ' Note that the constructor takes four argument values Private Sub mmuDisplayAmort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mmuDisplayAmort.Click ' Convert the four user input values from text to numeric formats gldblBegPrin = CType(txtBegPrin.Text, Double) gldblAddPymt = CType(txtAddPymt.Text, Double) glintPeriods = CType(txtPeriods.Text, Integer) glsngIntRate = CType(txtIntRate.Text, Single) rem gldblBegPrin = CDbl(txtBegPrin) rem gldblAddPymt = CDbl(txtAddPymt) rem glintPeriods = CInt(txtPeriods) rem glsngIntRate = CSng(txtIntRate) ' First, create an instance of the form named frmAmort using the four ' arguments: BegPrin, AddPymt, Periods, IntRate Dim frmAmortNew As New frmAmort(gldblBegPrin, _ gldblAddPymt, glintPeriods, glsngIntRate) ' Display the form frmAmort as a modeless dialog box frmAmortNew.Show() ' Set the Text property to update the contents of the title bar rem frmAmortNew.Text = "Amortization Schedule" ' Display the Initial Amount and Interest Rate text fields in frmAmort frmAmortNew.txtInitAmt.Text = gldblBegPrin.ToString("c") Dim sngTempIntRate As Single = (glsngIntRate * 100) Dim strTempIntRate As String = sngTempIntRate.ToString frmAmortNew.txtIntRate.Text = strTempIntRate & " %" End Sub ' Create an instance of the Help About form and display it. Private Sub mmuHelpAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mmuHelpAbout.Click Dim frmAboutNew As New frmAbout frmAboutNew.ShowDialog() End Sub ' Load initial values when the Main form frmMain.vb loads Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub ' Close the Main form frmMain.vb Private Sub mmuFileExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mmuFileExit.Click Me.Close() End Sub End Class