Welcome to Dream.In.Code
Become a VB Expert!

Join 137,233 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,791 people online right now. Registration is fast and FREE... Join Now!




Software Sales

 
Reply to this topicStart new topic

Software Sales

certaintragedy87
17 Feb, 2007 - 04:42 PM
Post #1

New D.I.C Head
*

Joined: 3 Feb, 2007
Posts: 5


My Contributions
i'm working on a project that is trying to calculate the discount on three different kind of packages, each worth different prices.

what we are given is
package A= $99
package B= $199
package C= $299

Quantity Discount
10 through 19 20%
20 through 49 30%
50 through 99 40%
100 or more 50%

with a message box that pops up when the user checks a "grand total" check box.

what i'm trying to figure out is how to write into the code the price of each package and then what discount each would get.

i would really appreciate some help on this! my code right now is a jumbled mess...

User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Software Sales
17 Feb, 2007 - 04:49 PM
Post #2

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,230



Thanked: 40 times
Dream Kudos: 25
My Contributions
If you would care to post what you have, we'd be glad to lend a hand.
User is online!Profile CardPM
+Quote Post

Jayman
RE: Software Sales
17 Feb, 2007 - 04:50 PM
Post #3

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,984



Thanked: 44 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
Store the package prices in separate variables ( so you will need 3 variabless for this).

You can use a Select/Case statement or a series of nested IF statements to determine which discount to use. Then store that discount value in another variable, perhaps called discount or something like that.

If you post the code you have completed so far. We will help you get it working.
User is online!Profile CardPM
+Quote Post

certaintragedy87
RE: Software Sales
17 Feb, 2007 - 04:52 PM
Post #4

New D.I.C Head
*

Joined: 3 Feb, 2007
Posts: 5


My Contributions
QUOTE(Amadeus @ 17 Feb, 2007 - 05:49 PM) *

If you would care to post what you have, we'd be glad to lend a hand.




Dim decPackageA As Decimal ' Package A amount
Dim decPackageB As Decimal ' Package B amount
Dim decPackageC As Decimal ' Package C amount
Dim decDiscount As Decimal ' Discount

(in between i IsNumeric code for input in the Package quantities)

' Calculate and display the total of the software order.
Select Case decDiscount
Case Is 10 to 19
decDiscount = 0.2D
Case Is 20 to 49
decDiscount = 0.3D
Case Is 50 to 99
decDiscount = 0.4D
Case Is >= 100
decDiscount = 0.5D
End Select

If chkGrandTotal.Checked = True Then
MessageBox.Show(txtAQuantity + txtBQuantity + txtCQuantity)

End If
User is offlineProfile CardPM
+Quote Post

VBisKillingMe
RE: Software Sales
8 Mar, 2007 - 06:16 AM
Post #5

New D.I.C Head
*

Joined: 8 Mar, 2007
Posts: 11


My Contributions
omg... I'm So glad to find that I'm not alone...

I have the same problem the person before had....

Here is my code so far... I wanted to use the IsNumeric funtion instead of MessageShow.Box to diplay to the user that they had to enter something numeric and no negative numbers are allowed. Can someone take a look at my code and give me some pointers. I think there is something wrong with my Dim statement for the lblErrorMessage. I am brand new to programming and I just DON't get it. I've spent countless hours on this.
Please Help!
CODE

  Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
        'Declare Variables for the calculations.
        Dim intPackageAQty As Integer
        Dim intPackageBQty As Integer
        Dim intPackageCQty As Integer
        Dim decAtotal As Decimal
        Dim decBtotal As Decimal
        Dim decCtotal As Decimal
        Dim decGrandTotal As Decimal

        Const decPackageDiscount10to19 As Decimal = 0.2
        Const decPacakgeDiscount50to99 As Decimal = 0.4
        Const decPackageDiscount20to49 As Decimal = 0.3
        Const decPackageDiscountOver100 As Decimal = 0.5
        Const decAprice As Decimal = 99
        Const decBprice As Decimal = 199
        Const decCprice As Decimal = 299



        If IsNumeric(txtPackageA.Text) = False Then
            lblErrorMessage.Text = "Quantity amount must be numberic. Negative numbers are also not accepted"
            lblErrorMessage.Visible = True
            Return
        End If

        If IsNumeric(txtPackageB.Text) = False Then
            lblErrorMessage.Text = "Quantity amount must be numberic. Negative numbers are also not accepted"
            lblErrorMessage.Visible = True
            Return
        End If

        If IsNumeric(txtPackageC.Text) = False Then
            lblErrorMessage.Text = "Quantity amount must be numberic. Negative numbers are also not accepted"
            lblErrorMessage.Visible = True
            Return
        End If

        ' Past this point, the user inputs contain software quantities.
        'Hide the error message label and do the calculations for
        'Package A.
        lblErrorMessage.Visible = False


        'calculating total price per package with discounts
        Select Case intPackageAQty
            Case Is < 10
                decAtotal = intPackageAQty * decAprice
            Case 10 To 19
                decAtotal = (intPackageAQty * decAprice) * decPackageDiscount10to19
            Case 20 To 49
                decAtotal = (intPackageAQty * decAprice) * decPackageDiscount20to49
            Case 50 To 99
                decAtotal = (intPackageAQty * decAprice) * decPacakgeDiscount50to99
            Case Is >= 100
                decAtotal = (intPackageAQty * decAprice) * decPackageDiscountOver100
        End Select
        Select Case intPackageBQty
            Case Is < 10
                decBtotal = intPackageBQty * decBprice
            Case 10 To 19
                decBtotal = (intPackageBQty * decBprice) * decPackageDiscount10to19
            Case 20 To 49
                decBtotal = (intPackageBQty * decBprice) * decPackageDiscount20to49
            Case 50 To 99
                decBtotal = (intPackageBQty * decBprice) * decPacakgeDiscount50to99
            Case Is >= 100
                decBtotal = (intPackageBQty * decBprice) * decPackageDiscountOver100
        End Select
        Select Case intPackageCQty
            Case Is < 10
                decCtotal = intPackageCQty * decCprice
            Case 10 To 19
                decCtotal = (intPackageBQty * decCprice) * decPackageDiscount10to19
            Case 20 To 49
                decCtotal = (intPackageBQty * decCprice) * decPackageDiscount20to49
            Case 50 To 99
                decCtotal = (intPackageBQty * decCprice) * decPacakgeDiscount50to99
            Case Is >= 100
                decAtotal = (intPackageBQty * decCprice) * decPackageDiscountOver100
        End Select

User is offlineProfile CardPM
+Quote Post

m2s87
RE: Software Sales
8 Mar, 2007 - 12:05 PM
Post #6

D.I.C Regular
Group Icon

Joined: 28 Nov, 2006
Posts: 390



Thanked: 1 times
Dream Kudos: 1225
My Contributions
QUOTE(VBisKillingMe @ 8 Mar, 2007 - 04:16 PM) *

omg... I'm So glad to find that I'm not alone...

I have the same problem the person before had....

Here is my code so far... I wanted to use the IsNumeric funtion instead of MessageShow.Box to diplay to the user that they had to enter something numeric and no negative numbers are allowed. Can someone take a look at my code and give me some pointers. I think there is something wrong with my Dim statement for the lblErrorMessage. I am brand new to programming and I just DON't get it. I've spent countless hours on this.
Please Help!
CODE

  Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
        'Declare Variables for the calculations.
        Dim intPackageAQty As Integer
        Dim intPackageBQty As Integer
        Dim intPackageCQty As Integer
        Dim decAtotal As Decimal
        Dim decBtotal As Decimal
        Dim decCtotal As Decimal
        Dim decGrandTotal As Decimal

        Const decPackageDiscount10to19 As Decimal = 0.2
        Const decPacakgeDiscount50to99 As Decimal = 0.4
        Const decPackageDiscount20to49 As Decimal = 0.3
        Const decPackageDiscountOver100 As Decimal = 0.5
        Const decAprice As Decimal = 99
        Const decBprice As Decimal = 199
        Const decCprice As Decimal = 299



        If IsNumeric(txtPackageA.Text) = False Then
            lblErrorMessage.Text = "Quantity amount must be numberic. Negative numbers are also not accepted"
            lblErrorMessage.Visible = True
            Return
        End If

        If IsNumeric(txtPackageB.Text) = False Then
            lblErrorMessage.Text = "Quantity amount must be numberic. Negative numbers are also not accepted"
            lblErrorMessage.Visible = True
            Return
        End If

        If IsNumeric(txtPackageC.Text) = False Then
            lblErrorMessage.Text = "Quantity amount must be numberic. Negative numbers are also not accepted"
            lblErrorMessage.Visible = True
            Return
        End If

        ' Past this point, the user inputs contain software quantities.
        'Hide the error message label and do the calculations for
        'Package A.
        lblErrorMessage.Visible = False


        'calculating total price per package with discounts
        Select Case intPackageAQty
            Case Is < 10
                decAtotal = intPackageAQty * decAprice
            Case 10 To 19
                decAtotal = (intPackageAQty * decAprice) * decPackageDiscount10to19
            Case 20 To 49
                decAtotal = (intPackageAQty * decAprice) * decPackageDiscount20to49
            Case 50 To 99
                decAtotal = (intPackageAQty * decAprice) * decPacakgeDiscount50to99
            Case Is >= 100
                decAtotal = (intPackageAQty * decAprice) * decPackageDiscountOver100
        End Select
        Select Case intPackageBQty
            Case Is < 10
                decBtotal = intPackageBQty * decBprice
            Case 10 To 19
                decBtotal = (intPackageBQty * decBprice) * decPackageDiscount10to19
            Case 20 To 49
                decBtotal = (intPackageBQty * decBprice) * decPackageDiscount20to49
            Case 50 To 99
                decBtotal = (intPackageBQty * decBprice) * decPacakgeDiscount50to99
            Case Is >= 100
                decBtotal = (intPackageBQty * decBprice) * decPackageDiscountOver100
        End Select
        Select Case intPackageCQty
            Case Is < 10
                decCtotal = intPackageCQty * decCprice
            Case 10 To 19
                decCtotal = (intPackageBQty * decCprice) * decPackageDiscount10to19
            Case 20 To 49
                decCtotal = (intPackageBQty * decCprice) * decPackageDiscount20to49
            Case 50 To 99
                decCtotal = (intPackageBQty * decCprice) * decPacakgeDiscount50to99
            Case Is >= 100
                decAtotal = (intPackageBQty * decCprice) * decPackageDiscountOver100
        End Select


Well i guess you could do this like:
CODE
class my1
  Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
  dim pacA as new my2
  dim pacB as new my2
  dim pacC as new my2

  if pacA.isNR=false or pacB.isNR=false or pacC.isNR=false then
      lblErrorMessage.Text = "Quantity amount must be numberic. Negative numbers are also not accepted"
            lblErrorMessage.Visible = True
            Return
  else
      decAtotal=pacA.decTot
      decBtotal=pacB.decTot
      decCtotal=pacC.decTot
  end if

  end sub
end class
class my2
        Const decPackageDiscount10to19 As Decimal = 0.2
        Const decPacakgeDiscount50to99 As Decimal = 0.4
        Const decPackageDiscount20to49 As Decimal = 0.3
        Const decPackageDiscountOver100 As Decimal = 0.5
        Const decAprice As Decimal = 99
        Const decBprice As Decimal = 199
        Const decCprice As Decimal = 299

        Dim intPackageQty As Integer
        Dim dectotal As Decimal
        Dim decprice As Decimal

        Public Property Total() As Decimal
           Get
              Return dectotal
           End Get
           Set(ByVal Value As Decimal)
              dectotal = value
           End Set
        End Property

        Public Property Price() As Decimal
           Get
              Return dectotal
           End Get
           Set(ByVal Value As Decimal)
              dectotal = value
           End Set
        End Property

        Public Property Package() As Integer
           Get
              Return intPackageQty
           End Get
           Set(ByVal Value As Integer)
              intPackageQty = value
              Select Case value
                 Case Is < 10: dectotal = value * decprice
                 Case 10 To 19:dectotal = value * decprice * decPackageDiscount10to19
            Case 20 To 49:dectotal = value * decprice * decPackageDiscount20to49
            Case 50 To 99:dectotal = value * decprice * decPacakgeDiscount50to99
            Case Is >= 100:dectotal = value * decprice * decPackageDiscountOver100
        End Select
           End Set
        End Property
end class

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 03:38PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month