' Gpa1 Example ' Input a grade points and credit hours. Output gpa. Public Class Form1 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 Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents btnCompute As System.Windows.Forms.Button Friend WithEvents txtGradePoints As System.Windows.Forms.TextBox Friend WithEvents txtCreditHours As System.Windows.Forms.TextBox Friend WithEvents txtGpa As System.Windows.Forms.TextBox Friend WithEvents Label3 As System.Windows.Forms.Label Private Sub InitializeComponent() Me.txtGradePoints = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.txtCreditHours = New System.Windows.Forms.TextBox Me.Label2 = New System.Windows.Forms.Label Me.btnCompute = New System.Windows.Forms.Button Me.txtGpa = New System.Windows.Forms.TextBox Me.Label3 = New System.Windows.Forms.Label Me.SuspendLayout() ' 'txtGradePoints ' Me.txtGradePoints.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtGradePoints.Location = New System.Drawing.Point(136, 24) Me.txtGradePoints.Name = "txtGradePoints" Me.txtGradePoints.Size = New System.Drawing.Size(128, 29) Me.txtGradePoints.TabIndex = 0 Me.txtGradePoints.Text = "" ' 'Label1 ' Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.Location = New System.Drawing.Point(8, 24) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(128, 24) Me.Label1.TabIndex = 1 Me.Label1.Text = "Grade Points" ' 'txtCreditHours ' Me.txtCreditHours.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtCreditHours.Location = New System.Drawing.Point(136, 64) Me.txtCreditHours.Name = "txtCreditHours" Me.txtCreditHours.Size = New System.Drawing.Size(128, 29) Me.txtCreditHours.TabIndex = 2 Me.txtCreditHours.Text = "" ' 'Label2 ' Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Location = New System.Drawing.Point(8, 64) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(128, 24) Me.Label2.TabIndex = 3 Me.Label2.Text = "Credit Hours" ' 'btnCompute ' Me.btnCompute.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.btnCompute.Location = New System.Drawing.Point(16, 144) Me.btnCompute.Name = "btnCompute" Me.btnCompute.Size = New System.Drawing.Size(248, 40) Me.btnCompute.TabIndex = 4 Me.btnCompute.Text = "Compute GPA" ' 'txtGpa ' Me.txtGpa.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtGpa.Location = New System.Drawing.Point(136, 104) Me.txtGpa.Name = "txtGpa" Me.txtGpa.Size = New System.Drawing.Size(128, 29) Me.txtGpa.TabIndex = 5 Me.txtGpa.Text = "" ' 'Label3 ' Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label3.Location = New System.Drawing.Point(80, 104) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(56, 24) Me.Label3.TabIndex = 6 Me.Label3.Text = "GPA" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(288, 206) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.txtGpa) Me.Controls.Add(Me.btnCompute) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.txtCreditHours) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.txtGradePoints) Me.Name = "Form1" Me.Text = "Gpa1 Example" Me.ResumeLayout(False) End Sub #End Region Private Sub btnCompute_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnCompute.Click Dim gradePoints, creditHours, gpa As Double gradePoints = txtGradePoints.Text creditHours = txtCreditHours.Text gpa = gradePoints / creditHours txtGpa.Text = gpa.ToString("0.000") End Sub End Class