( 69% 1 1 :33 VBQ\'s - Read-only Read Only - You can\'t save changes to this fil
ID: 3586286 • Letter: #
Question
Explanation / Answer
Main Form.Designer.vb
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmMain
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
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.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.txtScore1 = New System.Windows.Forms.TextBox()
Me.txtScore2 = New System.Windows.Forms.TextBox()
Me.btnCalc = New System.Windows.Forms.Button()
Me.btnExit = New System.Windows.Forms.Button()
Me.Label4 = New System.Windows.Forms.Label()
Me.lblAvg = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(27, 25)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(55, 17)
Me.Label1.TabIndex = 0
Me.Label1.Text = "Score &1:"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(27, 62)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(55, 17)
Me.Label2.TabIndex = 2
Me.Label2.Text = "Score &2:"
'
'txtScore1
'
Me.txtScore1.Location = New System.Drawing.Point(85, 22)
Me.txtScore1.Name = "txtScore1"
Me.txtScore1.Size = New System.Drawing.Size(51, 25)
Me.txtScore1.TabIndex = 1
'
'txtScore2
'
Me.txtScore2.Location = New System.Drawing.Point(85, 59)
Me.txtScore2.Name = "txtScore2"
Me.txtScore2.Size = New System.Drawing.Size(51, 25)
Me.txtScore2.TabIndex = 3
'
'btnCalc
'
Me.btnCalc.Location = New System.Drawing.Point(213, 22)
Me.btnCalc.Name = "btnCalc"
Me.btnCalc.Size = New System.Drawing.Size(87, 36)
Me.btnCalc.TabIndex = 4
Me.btnCalc.Text = "&Calculate"
Me.btnCalc.UseVisualStyleBackColor = True
'
'btnExit
'
Me.btnExit.Location = New System.Drawing.Point(213, 65)
Me.btnExit.Name = "btnExit"
Me.btnExit.Size = New System.Drawing.Size(87, 36)
Me.btnExit.TabIndex = 5
Me.btnExit.Text = "E&xit"
Me.btnExit.UseVisualStyleBackColor = True
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.Location = New System.Drawing.Point(27, 113)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(59, 17)
Me.Label4.TabIndex = 6
Me.Label4.Text = "Average:"
'
'lblAvg
'
Me.lblAvg.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.lblAvg.Location = New System.Drawing.Point(85, 112)
Me.lblAvg.Name = "lblAvg"
Me.lblAvg.Size = New System.Drawing.Size(73, 29)
Me.lblAvg.TabIndex = 7
Me.lblAvg.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'frmMain
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(7.0!, 17.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(341, 170)
Me.Controls.Add(Me.lblAvg)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.btnExit)
Me.Controls.Add(Me.btnCalc)
Me.Controls.Add(Me.txtScore2)
Me.Controls.Add(Me.txtScore1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Margin = New System.Windows.Forms.Padding(3, 5, 3, 5)
Me.Name = "frmMain"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Average Score Calculator"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents txtScore1 As System.Windows.Forms.TextBox
Friend WithEvents txtScore2 As System.Windows.Forms.TextBox
Friend WithEvents btnCalc As System.Windows.Forms.Button
Friend WithEvents btnExit As System.Windows.Forms.Button
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents lblAvg As System.Windows.Forms.Label
End Class
Main Form.vb
Option Explicit On
Option Strict On
Option Infer Off
Public Class frmMain
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
' calculates and displays the average of two test scores
' declare variables
Dim dblScore1 As Double
Dim dblScore2 As Double
Dim dblAverage As Double
' assign input to variables
Double.TryParse(txtScore1.Text, dblScore1)
Double.TryParse(txtScore2.Text, dblScore2)
' calculate average score
dblAverage = dblScore1 + dblScore2 / 2
' display average score
lblAvg.Text = dblAverage
End Sub
End Class
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.