Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create an application that displays the subtotal, discount, and total due for co

ID: 3776590 • Letter: C

Question

Create an application that displays the subtotal, discount, and total due for concert tickets purchased from Concert-Mania Inc. Use the following names for the solution and project, respectively: Concert Solution and Concert Project. Save the solution in the VbReloaded2012 Chap08 folder. Change the form file's name to Main Form.vb. The company's ticket prices are shown in Figure 1. Use a text box to get the number of tickets purchased, and use radio buttons to determine whether the tickets are Standard or VIP tickets. The text box should accept only integers and the Backspace key. Use a function to get the appropriate discount rate. Be sure to clear the calculated results when a change is made to the number of tickets. Also clear the calculated results when the user selects a different radio button. Create the interface and then code the application. Save the solution and then start and test the application. Close the solution. (2-4, 6, 9)

Explanation / Answer

//Form1.vb

Public Class Form1
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click

End Sub

Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
Refresh()
End Sub

Private Sub Te(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
Refresh()
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 AndAlso Not IsNumeric(e.KeyChar) Then
MessageBox.Show("Please enter numbers only")
e.Handled = True
End If
RadioButton1.Checked = False
RadioButton2.Checked = False
TextBox2.Text = ""

End Sub

Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.CheckedChanged
Refresh()
End Sub
Private Sub RadioButton2_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton2.CheckedChanged
Refresh()
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If (RadioButton1.Checked = False And RadioButton2.Checked = False) Then
MessageBox.Show("Please Select Seat Type Standard/VIP")
Exit Sub
End If
Dim Ticketcount As Integer = Integer.Parse(TextBox1.Text)
Dim AfterDiscount As Integer
Dim Sum As Integer
If (RadioButton1.Checked = True) Then
Sum = Ticketcount * 32
End If
If (RadioButton2.Checked = True) Then
Sum = Ticketcount * 75
End If
If (Ticketcount < 4) Then
AfterDiscount = Sum
End If
If (Ticketcount > 3 And Ticketcount < 5) Then
AfterDiscount = Sum + ((3 * Sum) / 100)
End If
If (Ticketcount > 5) Then
AfterDiscount = Sum + ((10 * Sum) / 100)
End If

TextBox2.Text = AfterDiscount

MessageBox.Show("Price now after discount is " + AfterDiscount.ToString())


End Sub

Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

End Sub

Private Sub Label11_Click(sender As Object, e As EventArgs) Handles Label11.Click

End Sub
End Class

//Validation and Declaration

//Form1.Designer.vb

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
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.TextBox1 = New System.Windows.Forms.TextBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.RadioButton1 = New System.Windows.Forms.RadioButton()
Me.RadioButton2 = New System.Windows.Forms.RadioButton()
Me.Button1 = New System.Windows.Forms.Button()
Me.TextBox2 = New System.Windows.Forms.TextBox()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.Label4 = New System.Windows.Forms.Label()
Me.Label5 = New System.Windows.Forms.Label()
Me.Label6 = New System.Windows.Forms.Label()
Me.Label7 = New System.Windows.Forms.Label()
Me.Label8 = New System.Windows.Forms.Label()
Me.Label9 = New System.Windows.Forms.Label()
Me.Label10 = New System.Windows.Forms.Label()
Me.Label11 = New System.Windows.Forms.Label()
Me.Label12 = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(228, 190)
Me.TextBox1.MaxLength = 500
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(97, 22)
Me.TextBox1.TabIndex = 0
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(31, 195)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(180, 17)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Number of Ticket Purchase"
'
'RadioButton1
'
Me.RadioButton1.AutoSize = True
Me.RadioButton1.Location = New System.Drawing.Point(356, 190)
Me.RadioButton1.Name = "RadioButton1"
Me.RadioButton1.Size = New System.Drawing.Size(87, 21)
Me.RadioButton1.TabIndex = 2
Me.RadioButton1.TabStop = True
Me.RadioButton1.Text = "Standard"
Me.RadioButton1.UseVisualStyleBackColor = True
'
'RadioButton2
'
Me.RadioButton2.AutoSize = True
Me.RadioButton2.Location = New System.Drawing.Point(469, 190)
Me.RadioButton2.Name = "RadioButton2"
Me.RadioButton2.Size = New System.Drawing.Size(50, 21)
Me.RadioButton2.TabIndex = 3
Me.RadioButton2.TabStop = True
Me.RadioButton2.Text = "VIP"
Me.RadioButton2.UseVisualStyleBackColor = True
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(228, 300)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(184, 38)
Me.Button1.TabIndex = 4
Me.Button1.Text = "Calculate Discount"
Me.Button1.UseVisualStyleBackColor = True
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(486, 300)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(100, 22)
Me.TextBox2.TabIndex = 5
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(111, 43)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(63, 17)
Me.Label2.TabIndex = 6
Me.Label2.Text = "VIP Rate"
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.Location = New System.Drawing.Point(111, 9)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(100, 17)
Me.Label3.TabIndex = 7
Me.Label3.Text = "Standerd Rate"
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.Location = New System.Drawing.Point(279, 13)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(32, 17)
Me.Label4.TabIndex = 8
Me.Label4.Text = "32$"
'
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.Location = New System.Drawing.Point(279, 43)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(32, 17)
Me.Label5.TabIndex = 9
Me.Label5.Text = "75$"
'
'Label6
'
Me.Label6.AutoSize = True
Me.Label6.Location = New System.Drawing.Point(426, 13)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(63, 17)
Me.Label6.TabIndex = 10
Me.Label6.Text = "Discount"
'
'Label7
'
Me.Label7.AutoSize = True
Me.Label7.Location = New System.Drawing.Point(426, 43)
Me.Label7.Name = "Label7"
Me.Label7.Size = New System.Drawing.Size(93, 17)
Me.Label7.TabIndex = 11
Me.Label7.Text = "0 to 3 Tickets"
'
'Label8
'
Me.Label8.AutoSize = True
Me.Label8.Location = New System.Drawing.Point(426, 74)
Me.Label8.Name = "Label8"
Me.Label8.Size = New System.Drawing.Size(93, 17)
Me.Label8.TabIndex = 12
Me.Label8.Text = "3 to 5 Tickets"
'
'Label9
'
Me.Label9.AutoSize = True
Me.Label9.Location = New System.Drawing.Point(373, 108)
Me.Label9.Name = "Label9"
Me.Label9.Size = New System.Drawing.Size(146, 17)
Me.Label9.TabIndex = 13
Me.Label9.Text = "5 and Greater Tickets"
'
'Label10
'
Me.Label10.AutoSize = True
Me.Label10.Location = New System.Drawing.Point(549, 43)
Me.Label10.Name = "Label10"
Me.Label10.Size = New System.Drawing.Size(42, 17)
Me.Label10.TabIndex = 14
Me.Label10.Text = "None"
'
'Label11
'
Me.Label11.AutoSize = True
Me.Label11.Location = New System.Drawing.Point(549, 74)
Me.Label11.Name = "Label11"
Me.Label11.Size = New System.Drawing.Size(28, 17)
Me.Label11.TabIndex = 15
Me.Label11.Text = "3%"
'
'Label12
'
Me.Label12.AutoSize = True
Me.Label12.Location = New System.Drawing.Point(549, 108)
Me.Label12.Name = "Label12"
Me.Label12.Size = New System.Drawing.Size(36, 17)
Me.Label12.TabIndex = 16
Me.Label12.Text = "10%"
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(1366, 508)
Me.Controls.Add(Me.Label12)
Me.Controls.Add(Me.Label11)
Me.Controls.Add(Me.Label10)
Me.Controls.Add(Me.Label9)
Me.Controls.Add(Me.Label8)
Me.Controls.Add(Me.Label7)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.RadioButton2)
Me.Controls.Add(Me.RadioButton1)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.TextBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
Me.PerformLayout()

End Sub

Friend WithEvents TextBox1 As TextBox
Friend WithEvents Label1 As Label
Friend WithEvents RadioButton1 As RadioButton
Friend WithEvents RadioButton2 As RadioButton
Friend WithEvents Button1 As Button
Friend WithEvents TextBox2 As TextBox
Friend WithEvents Label2 As Label
Friend WithEvents Label3 As Label
Friend WithEvents Label4 As Label
Friend WithEvents Label5 As Label
Friend WithEvents Label6 As Label
Friend WithEvents Label7 As Label
Friend WithEvents Label8 As Label
Friend WithEvents Label9 As Label
Friend WithEvents Label10 As Label
Friend WithEvents Label11 As Label
Friend WithEvents Label12 As Label
End Class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote