Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need the solution (Code) for Clearly Visual Basic, 3rd Edition, Chapter 5, Page 104, Exercise 11?In this exercise, you finish coding the Average Solution

I need the solution (Code) for Clearly Visual Basic, 3rd Edition, Chapter 5, Page 104, Exercise 11?In this exercise, you finish coding the Average Solution Folder. (I submitted the question as well for this ecxercise) Center the average. Complete the chart shown in figure 4-21 and then code the algorithm. Public Class frmMain Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load MaximizeBox = False End Sub ' *********** Calculate Button click procedure ******************** Private Sub btn_calculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_calculate.Click ' Checking whether any input was provided or not if not then display the message to the user If tb_num1.Text.Equals("") Then MessageBox.Show("Please enter the 1st number", "Message") ElseIf tb_num2.Text.Equals("") Then MessageBox.Show("Please enter the 2nd number", "Message") ElseIf tb_num3.Text.Equals("") Then MessageBox.Show("Please enter the 3rd number", "Message") Else ' If all the 3 inputs were provided then execute this block Dim Num1 As Double Dim Num2 As Double Dim Num3 As Double Dim Average As Double Try ' trying to parse the input numbers to double Num1 = Double.Parse(tb_num1.Text) Num2 = Double.Parse(tb_num2.Text) Num3 = Double.Parse(tb_num3.Text) ' If successful to parse then calculate the average Average = (Num1 + Num2 + Num3) / 3 MessageBox.Show("Average of the input numbers is: " + Math.Round(Average, 2).ToString, "Average") Catch ex As Exception ' If unsuccessful to parse then display the below error messsage MessageBox.Show("All the three input must be in numbers only", "ERROR") End Try End If End Sub ' ************ Exit button click procedure ********************* Private Sub btn_exit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_exit.Click Me.Close() End Sub ' ************** Clear button click procedure ***************** Private Sub btn_clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_clear.Click tb_num1.Text = "" tb_num2.Text = "" tb_num3.Text = "" End Sub End Class ------------- ------------ _ Partial Class frmMain Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. _ 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. _ Private Sub InitializeComponent() Me.GroupBox1 = New System.Windows.Forms.GroupBox() Me.Label1 = New System.Windows.Forms.Label() Me.Label2 = New System.Windows.Forms.Label() Me.Label3 = New System.Windows.Forms.Label() Me.tb_num1 = New System.Windows.Forms.TextBox() Me.tb_num2 = New System.Windows.Forms.TextBox() Me.tb_num3 = New System.Windows.Forms.TextBox() Me.btn_calculate = New System.Windows.Forms.Button() Me.btn_exit = New System.Windows.Forms.Button() Me.btn_clear = New System.Windows.Forms.Button() Me.GroupBox1.SuspendLayout() Me.SuspendLayout() ' 'GroupBox1 ' Me.GroupBox1.Controls.Add(Me.tb_num3) Me.GroupBox1.Controls.Add(Me.tb_num2) Me.GroupBox1.Controls.Add(Me.tb_num1) Me.GroupBox1.Controls.Add(Me.Label3) Me.GroupBox1.Controls.Add(Me.Label2) Me.GroupBox1.Controls.Add(Me.Label1) Me.GroupBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.GroupBox1.Location = New System.Drawing.Point(39, 44) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(268, 134) Me.GroupBox1.TabIndex = 0 Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "Enter the three numbers" ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(140, 35) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(76, 16) Me.Label1.TabIndex = 0 Me.Label1.Text = "1st Number" ' 'Label2 ' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point(140, 69) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(81, 16) Me.Label2.TabIndex = 1 Me.Label2.Text = "2nd Number" ' 'Label3 ' Me.Label3.AutoSize = True Me.Label3.Location = New System.Drawing.Point(140, 103) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(78, 16) Me.Label3.TabIndex = 2 Me.Label3.Text = "3rd Number" ' 'tb_num1 ' Me.tb_num1.Location = New System.Drawing.Point(19, 32) Me.tb_num1.Name = "tb_num1" Me.tb_num1.Size = New System.Drawing.Size(100, 22) Me.tb_num1.TabIndex = 1 ' 'tb_num2 ' Me.tb_num2.Location = New System.Drawing.Point(19, 64) Me.tb_num2.Name = "tb_num2" Me.tb_num2.Size = New System.Drawing.Size(100, 22) Me.tb_num2.TabIndex = 2 ' 'tb_num3 ' Me.tb_num3.Location = New System.Drawing.Point(19, 96) Me.tb_num3.Name = "tb_num3" Me.tb_num3.Size = New System.Drawing.Size(100, 22) Me.tb_num3.TabIndex = 3 ' 'btn_calculate ' Me.btn_calculate.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.btn_calculate.Location = New System.Drawing.Point(39, 216) Me.btn_calculate.Name = "btn_calculate" Me.btn_calculate.Size = New System.Drawing.Size(75, 40) Me.btn_calculate.TabIndex = 4 Me.btn_calculate.Text = "Calculate" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "Average" Me.btn_calculate.UseVisualStyleBackColor = True ' 'btn_exit ' Me.btn_exit.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.btn_exit.Location = New System.Drawing.Point(232, 216) Me.btn_exit.Name = "btn_exit" Me.btn_exit.Size = New System.Drawing.Size(75, 40) Me.btn_exit.TabIndex = 5 Me.btn_exit.Text = "Exit" Me.btn_exit.UseVisualStyleBackColor = True ' 'btn_clear ' Me.btn_clear.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.btn_clear.Location = New System.Drawing.Point(137, 216) Me.btn_clear.Name = "btn_clear" Me.btn_clear.Size = New System.Drawing.Size(75, 40) Me.btn_clear.TabIndex = 6 Me.btn_clear.Text = "Clear " Me.btn_clear.UseVisualStyleBackColor = True ' 'frmMain ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(345, 313) Me.Controls.Add(Me.btn_clear) Me.Controls.Add(Me.btn_exit) Me.Controls.Add(Me.btn_calculate) Me.Controls.Add(Me.GroupBox1) Me.Name = "frmMain" Me.Text = "Average Calculator App." Me.GroupBox1.ResumeLayout(False) Me.GroupBox1.PerformLayout() Me.ResumeLayout(False) End Sub Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox Friend WithEvents tb_num3 As System.Windows.Forms.TextBox Friend WithEvents tb_num2 As System.Windows.Forms.TextBox Friend WithEvents tb_num1 As System.Windows.Forms.TextBox Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents btn_calculate As System.Windows.Forms.Button Friend WithEvents btn_exit As System.Windows.Forms.Button Friend WithEvents btn_clear As System.Windows.Forms.Button End Class

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions