Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15038

VS 2012 Visual Basic 201 How to Program Deitel Exercise 5.5 Retail Sales Calculator Applicati

$
0
0
good day,

could someone please assist me with the code below as my solution doesnt match the example in the textbook. i have attached 2 files to show what the solution looks like.

many thanks

Code:

Public Class retailSalesCalculator
    Private Sub retailSalesCalculator_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub
    Private Sub submitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submitButton.Click
        'store the product selected and quantity sold

        Dim product1 As Decimal 'price of product 1

        Dim product2 As Decimal 'price of product 2

        Dim product3 As Decimal 'price of product 3

        Dim product4 As Decimal 'price of product 4

        Dim product5 As Decimal 'price of product 5

        Dim quantitySold As Integer = Val(quantitySoldTextBox.Text) 'count of amount of each product sold

        Select Case productUpDown.Value()

            Case 1

                product1 = 2.98

            Case 2

                product2 = 4.5

            Case 3

                product3 = 9.98

            Case 4

                product4 = 4.49

            Case 5

                product5 = 6.87

        End Select

        'calculate amount after each product and quantity entered and add to outputListBox

        Dim product1total As Decimal

        Dim product2total As Decimal

        Dim product3total As Decimal

        Dim product4total As Decimal

        Dim product5total As Decimal

        Dim overalltotal As Decimal



        If productUpDown.Value() = 1 Then
            product1total = product1 * quantitySold
        End If






        If productUpDown.Value() = 2 Then
            product2total = product2 * quantitySold
        End If



        If productUpDown.Value() = 3 Then
            product3total = product3 * quantitySold
        End If



        If productUpDown.Value() = 4 Then
            product4total = product4 * quantitySold
        End If



        If productUpDown.Value() = 5 Then

            product5total = product5 * quantitySold

        End If


        outputLabel.Text = ("Product 1: " & String.Format("{0:C}", product1total))

        outputLabel.Text = ("Product 2: " & String.Format("{0:C}", product2total))

        outputLabel.Text = ("Product 3: " & String.Format("{0:C}", product3total))

        outputLabel.Text = ("Product 4: " & String.Format("{0:C}", product4total))

        outputLabel.Text = ("Product 5: " & String.Format("{0:C}", product5total))




        overalltotal = product1total + product2total + product3total + product4total + product5total


        outputLabel.Text = product1total & product2total & product3total & product4total & product5total & overalltotal

        outputLabel.Text = ("Product 1: " & String.Format("{0:C}", product1total)) & Environment.NewLine & ("Product 2: " & String.Format("{0:C}", product2total)) & Environment.NewLine & ("Product 3: " & String.Format("{0:C}", product3total)) & Environment.NewLine & ("Product 4: " & String.Format("{0:C}", product4total)) & Environment.NewLine & ("Product 5: " & String.Format("{0:C}", product5total)) & Environment.NewLine & ("Total of all products sold: " & String.Format("{0:C}", overalltotal))

        quantitySoldTextBox.Clear()



    End Sub 'submitButton_Click



    Private Sub resetButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles resetButton.Click

        outputLabel.Text = "" 'clears outputLabel results

        quantitySoldTextBox.Text = String.Empty 'clears qantitySoldTextBox

    End Sub



End Class

Attached Images
  

Viewing all articles
Browse latest Browse all 15038

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>