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

Programming in Visual Basic 2010 Can someone help me with chapter 3 Very Very Bo

ID: 3755176 • Letter: P

Question

Programming in Visual Basic 2010 Can someone help me with chapter 3 Very Very Boards code?

I need the programming code for following project. Thank you.

Very Very Boards rents snowboards during the snow season. A person can rent a snowboard without boots or with boots. Create a project that will calculate and display the information for each rental. In addition, calculate the summary information for each day’s rentals.

For each rental, input the person’s name, the driver’s license or ID number, the number of snowboards, and the number of snowboards with boots. Snowboards without boots rent for $20; snowboards with boots rent for $30.

Calculate and display the charges for snowboards and snowboards with boots, and the rental total. In addition, maintain summary totals. Use constants for the snowboard rental rate and the snowboard with boots rental rate.

Create a summary frame with boxes to indicate the day’s totals for the number of snowboards and snowboards with boots rented, total charges, and average charge per customer.

Include buttons for Calculate Order,Clear,Clear All, Print, and Exit. The Clear Allcommand should clear the summary totals to begin a new day’s summary. Hint: You must set each of the summary variables to zero as well as clear the summary boxes.

Make your buttons easy to use for keyboard entry. Make the Calculatebutton the Accept button and the Clearbutton the Cancel button.

Do not allow bad input data to cancel the program; instead display a message to the user.

Explanation / Answer

Screenshot

-------------------------------------------------------------

Program

'Inorder to make the Calculate Button (btnCalculate) an Accept Button, open the properties of form and change the
'AcceptButton Property to btnCalculate

'Inorder to make the Clear Button (btnClear) a Cancel Button, open the properties of form and change the
'CancelButton Property to btnClear

'txtLicNo property maxLength set to 16

Public Class frmSnowboard
    'Constant initialization
    Public Const sbWBoots = 30
    Public Const sbNoBoots = 20
    'Global variables
    Dim totalDaySBWBoots As Int32 = 0
    Dim totalDaySBNoBoots As Int32 = 0
    Dim noCustomer As Int32 = 0
    'Calculate button event
    Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
        'Check all required text boxes ok
        If (txtName.Text = "") Then
            MsgBox("Please enter name!!!")
            txtName.Select()
        End If
        If (txtLicNo.Text = "") Then
            MsgBox("Please enter licence number!!!")
            txtLicNo.Select()
        End If
        If (txtNoSBWOBoots.Text = "") Then
            MsgBox("Please enter number of snow board without boots!!!")
            txtNoSBWOBoots.Select()
        End If
        If (txtNoSBWBoots.Text = "") Then
            MsgBox("Please enter number of snow board with boots!!!")
            txtNoSBWBoots.Select()
        End If
        'Calculate and print
        txtChgSBWOBoots.Text = "$" + (txtNoSBWOBoots.Text * sbNoBoots).ToString()
        txtChgSBWBoots.Text = "$" + (txtNoSBWBoots.Text * sbWBoots).ToString()
        totalDaySBWBoots += (txtNoSBWOBoots.Text * sbNoBoots)
        totalDaySBNoBoots += (txtNoSBWBoots.Text * sbWBoots)
        txtRent.Text = "$" + ((txtNoSBWOBoots.Text * sbNoBoots) + (txtNoSBWBoots.Text * sbWBoots)).ToString()
        noCustomer += 1
    End Sub
    'Alowed only alphabet and space
    Private Sub txtName_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtName.KeyPress
        If Not (Asc(e.KeyChar) = 8) Then
            Dim allowedChars As String = "abcdefghijklmnopqrstuvwxyz "
            If Not allowedChars.Contains(e.KeyChar.ToString.ToLower) Then
                e.KeyChar = ChrW(0)
                e.Handled = True
            End If
        End If
    End Sub
    'Alowed only alphanumeric and '-' character and max length of data 16
    Private Sub txtLicNo_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtLicNo.KeyPress
        If Not (Asc(e.KeyChar) = 8) Then
            Dim allowedChars As String = "abcdefghijklmnopqrstuvwxyz-01234569"
            If Not allowedChars.Contains(e.KeyChar.ToString.ToLower) Then
                e.KeyChar = ChrW(0)
                e.Handled = True
            End If
        End If
    End Sub
    'Allow only numeric data
    Private Sub txtNoSBWOBoots_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtNoSBWOBoots.KeyPress
        If Not Char.IsDigit(e.KeyChar) And Not Char.IsControl(e.KeyChar) Then
            e.Handled = True
        End If
    End Sub
    'Allow only numeric data
    Private Sub txtNoSBWBoots_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtNoSBWBoots.KeyPress
        If Not Char.IsDigit(e.KeyChar) And Not Char.IsControl(e.KeyChar) Then
            e.Handled = True
        End If
    End Sub
    'Clear User entry and one time calculation
    Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
        txtName.Text = ""
        txtLicNo.Text = ""
        txtNoSBWBoots.Text = ""
        txtNoSBWOBoots.Text = ""
        txtChgSBWBoots.Text = ""
        txtChgSBWOBoots.Text = ""
        txtRent.Text = ""
        txtName.Select()
    End Sub
    'Focus on first text box
    Private Sub frmSnowboard_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        txtName.Select()
    End Sub
    'Print summary
    Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles btnPrint.Click
        txtTotChgSBWBoots.Text = "$" + totalDaySBWBoots.ToString()
        txtTotChgSBWOBoots.Text = "$" + totalDaySBNoBoots.ToString()
        txtTotRent.Text = "$" + (totalDaySBWBoots + totalDaySBNoBoots).ToString()
        txtAvg.Text = "$" + ((totalDaySBWBoots + totalDaySBNoBoots) / noCustomer).ToString()

    End Sub
    'Clear the form data and start fresh
    Private Sub btnClearAll_Click(sender As Object, e As EventArgs) Handles btnClearAll.Click
        txtName.Text = ""
        txtLicNo.Text = ""
        txtNoSBWBoots.Text = ""
        txtNoSBWOBoots.Text = ""
        txtChgSBWBoots.Text = ""
        txtChgSBWOBoots.Text = ""
        txtRent.Text = ""
        txtTotChgSBWBoots.Text = ""
        txtTotChgSBWOBoots.Text = ""
        txtTotRent.Text = ""
        txtAvg.Text = ""
        txtName.Select()
        totalDaySBWBoots = 0
        totalDaySBNoBoots = 0
        noCustomer = 0
    End Sub
    'Exit from program
    Private Sub cmdExit_Click(sender As Object, e As EventArgs) Handles cmdExit.Click
        Dim result = MessageBox.Show(" Are you sure you want to quit", "Are you sure?", MessageBoxButtons.YesNo)
        If result = DialogResult.Yes Then
            Me.Close()
        ElseIf result = DialogResult.No Then
            txtName.Select()
        End If
    End Sub
End Class