You are here: DEVPPL Forum Programming Visual Basic Forum
NOTIFICATIONS
54.107
MEMBERS
15.696
TOPICS
62.284
POSTS
  562
FLASH GAMES
7.740
TUTORIALS
 

Login

E-mail:
Password:

some help with Visual Basic rental program.

0

Loading

some help with Visual Basic rental program.

Postby Racerx » Sun Oct 30, 2011 3:16 am

I am using VB Studio 2010 and I can't seem to get the summary of the First and Last Name to combine in the FullName below. It's a Snowboard rental program in Visual Basic. Also, the Driver's License is another thing I can't get to work. I am new to Visual Basic, so please bear with me.


Code: Select all

'Project:           Very Very Snowboards
'Date:              10/22/2011
'Programmer:        X
'Description:      This program inputs sales information for snowboard rental and snowboard rental with boots. It gives output the total snowboards rented,
'                   total snowboards with boots rented, total charges, and average total charges per customer.

Option Strict On

Public Class VeryVerySnowBoards

    'Declare the variables and constants in module-level.

    Private FirstNameTextBoxString As String
    Private LastNameTextBoxString As String
    Private FirstNameString As String
    Private LastNameString As String
    Private FullNameTextBoxString As String
    Private FullNameString As String
    Private DriversLicenseTextBoxString As String
    Private DriversLicenseString As String
    Private NumberofSnowboardsRentedInteger As Integer
    Private NumberOfSnowboardsWithBootsRentedInteger As Integer
    Private TotalSnowboardsRentedString As String
    Private TotalSnowboardsWithBootsRentedString As String
    Private TotalChargesTextBoxDecimal As Decimal
    Private TotalCustomersTextBoxInteger As Integer
    Private AverageChargePerCustomerTextBoxDecimal As Decimal


    Const RENT_COST_PER_BOARD_Decimal As Decimal = 20D
    Const RENT_COST_PER_BOARD_WITH_BOOTS_Decimal As Decimal = 30D

    Private Sub FirstName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FirstNameTextBox.TextChanged
        'Declare first name.



        FirstNameTextBoxString = FirstNameTextBox.Text


    End Sub

    Private Sub LastName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LastNameTextBox.TextChanged
        'Declare last name.


        LastNameTextBoxString = LastNameTextBox.Text


    End Sub

    Private Sub FullNameTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FullNameTextBox.TextChanged


        FullNameTextBoxString = FirstNameTextBoxString & "" & LastNameTextBoxString


    End Sub




    Private Sub DriversLicense_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DriversLicense.TextChanged
        'Declare driver's license.

        DriversLicenseTextBox.Text = DriversLicenseString

    End Sub
    Private Sub CalculateOrder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateOrder.Click

        'Calculate transaction total while providing the amount of transaction totals to daily totals.
        'Calculate the values of the rentals.

        'Declare on the DIM level.

        Dim TotalSnowboardsRentedTextBoxInteger As Integer
        Dim TotalSnowBoardsWithBootsRentedTextBoxInteger As Integer
        Dim NumberOfSnowboardsRentedInteger As Integer
        Dim NumberOfSnowboardsWithBootsRentedInteger As Integer
        Dim NumberOfSnowboardsRentedDecimal As Decimal
        Dim NumberOfSnowboardsWithBootsRentedDecimal As Decimal
        Dim TotalChargesTextBoxDecimal As Decimal
        Dim AverageChargePerCustomerTextBoxDecimal As Decimal
        Dim TotalCustomersTextBoxInteger As Integer
        Dim CostOfRentalTextBoxDecimal As Decimal


        Try

           
            'Convert snowboards only as a numeric variable.
            NumberOfSnowboardsRentedInteger = Integer.Parse(NumberOfSnowboardsRentedTextBox.Text)

            Try

                'Convert snowboards with boots as a numeric variable.
                NumberOfSnowboardsWithBootsRentedInteger = Integer.Parse(NumberOfSnowboardsWithBootsRentedTextBox.Text)

                'Calculate individual values for Snowboards only and Snowboards with Boots.

                NumberOfSnowboardsRentedDecimal = NumberOfSnowboardsRentedInteger * RENT_COST_PER_BOARD_Decimal
                NumberOfSnowboardsWithBootsRentedDecimal = NumberOfSnowboardsWithBootsRentedInteger * RENT_COST_PER_BOARD_WITH_BOOTS_Decimal
                CostOfRentalTextBoxDecimal = NumberOfSnowboardsRentedDecimal + NumberOfSnowboardsWithBootsRentedDecimal

                'Format and display for customer charges.

                NumberOfSnowboardsRentedTextBox.Text = NumberOfSnowboardsRentedInteger.ToString
                NumberOfSnowboardsWithBootsRentedTextBox.Text = NumberOfSnowboardsWithBootsRentedInteger.ToString
                TotalChargesTextBox.Text = TotalChargesTextBoxDecimal.ToString("C")
                CostOfRentalTextBox.Text = CostOfRentalTextBoxDecimal.ToString("C")

                'Add to Daily Total.
                TotalSnowboardsRentedTextBoxInteger += NumberOfSnowboardsRentedInteger
                TotalSnowBoardsWithBootsRentedTextBoxInteger += NumberOfSnowboardsWithBootsRentedInteger
                TotalCustomersTextBoxInteger += 1
                TotalChargesTextBoxDecimal += CostOfRentalTextBoxDecimal
                AverageChargePerCustomerTextBoxDecimal = TotalChargesTextBoxDecimal / TotalCustomersTextBoxInteger


                'Display as Currency and daily totals.


                TotalSnowboardsRentedTextBox.Text = TotalSnowboardsRentedTextBoxInteger.ToString
                TotalSnowboardsWithBootsRentedTextBox.Text = TotalSnowBoardsWithBootsRentedTextBoxInteger.ToString
                TotalCustomersTextBox.Text = TotalCustomersTextBoxInteger.ToString
                TotalChargesTextBox.Text = TotalChargesTextBoxDecimal.ToString("C")
                AverageChargePerCustomerTextBox.Text = AverageChargePerCustomerTextBoxDecimal.ToString("C")
               


            Catch SnowboardsWithBootsException As FormatException

                'Handle the number of boots.

                MessageBox.Show("Please Input the number of Snowboards rented with boots.",
                "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

                With NumberOfSnowboardsWithBootsRentedTextBox
                    .Focus()
                    .SelectAll()
                End With

            End Try

        Catch SnowboardsException As FormatException

            'Handle the number of snowboards.

            MessageBox.Show("Please Input Number of Snowboards rented.",
            "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

            With NumberOfSnowboardsRentedTextBox
                .Focus()
                .SelectAll()
            End With
        Catch AnException As Exception
            MessageBox.Show("Error:" & AnException.Message)
        End Try



    End Sub

    Private Sub ClearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButton.Click
        'Clears all data from current transaction.

        NumberOfSnowboardsRentedTextBox.Clear()
        NumberOfSnowboardsWithBootsRentedTextBox.Clear()
        DriversLicense.Clear()
        FirstNameTextBox.Clear()
        LastNameTextBox.Clear()


    End Sub

    Private Sub PrintButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintButton.Click
        'Print the form.

        PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
        PrintForm1.Print()
    End Sub



    Private Sub ClearAllButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearAllButton.Click
        'Clear all daily amounts from the form.

        TotalSnowboardsRentedTextBox.Clear()
        TotalSnowboardsWithBootsRentedTextBox.Clear()
        TotalChargesTextBox.Clear()
        TotalCustomersTextBox.Clear()
        AverageChargePerCustomerTextBox.Clear()
        FullNameTextBox.Clear()
        DriversLicenseTextBox.Clear()
        CostOfRentalTextBox.Clear()

        With TotalCustomersTextBox
            .Clear()
            .Focus()
        End With

        TotalSnowboardsRentedInteger = 0
        TotalSnowboardsWithBootsRentedInteger = 0
        TotalCustomersInteger = 0
        TotalChargesDecimal = 0
        AverageChargePerCustomerDecimal = 0





    End Sub


    Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
        'Exit the project.

        Me.Close()

    End Sub

End Class

Racerx
 
Reputation: 0
Posts: 1
Joined: Sun Oct 30, 2011 2:57 am
Highscores: 0
Arcade winning challenges: 0

some help with Visual Basic rental program. - Sponsored results

Sponsored results

Login to get rid of ads

 

0

Loading

Re: some help with Visual Basic rental program.

Postby Sanjon » Thu Nov 10, 2011 10:28 pm

First of, sorry for the late reply. I don't come here very often. But here is what you should do to fix the full name thing:

1. You don't need the LastName.TextChange sub. If I got you right, you want to update the full name whenever the first or last name field gets changed, not when the full name field gets changed.

2. Add the following to FirstName.TextChanged and LastName.TextChanged:

Code: Select all
FullNameString = FirstNameString & " " & LastNameString


I might have gotten some of the variables' names wrong, so you may need to correct that first. BTW if you want to make the full name show in the full name textbox, you can also add this line to FirstName.TextChanged and LastName.TextChanged:

Code: Select all
FullNameTextBox.Text = FullNameString


Tell me if you don't understand something or it doesn't work.
Sanjon
 
Reputation: 0
Posts: 40
Joined: Sun Dec 05, 2010 7:20 pm
Highscores: 0
Arcade winning challenges: 0
^ Back to Top