| You are here: DEVPPL ‹ Forum ‹ Programming ‹ Visual Basic Forum |
NOTIFICATIONS
|
|
|||||||||||||||
Login |
Help please. Thank you.
2 posts
• Page 1 of 1
0
Help please. Thank you.
I need help. I’m taking a class in Visual Basic (and no I don’t want you to do my homework for me). I don’t understand what is going wrong with my coding (please note I haven’t finished all of the coding because I need to get the first part right first). Here is the topic: (Part 1) Lynette Rifle owns an image consulting shop. Her clients can select from the following services at the specified regular prices: makeover $125, Hair Styling $60, Manicure $35, and Permanent Makeup $200. She has distributed discount coupons that advertise discounts of 10 percent and 20 percent off the regular price. Create a project that will allow the receptionist to select a discount rate of 10 percent, 20 percent, or none, and then select a service. Display the total price for the currently selected service and the total due for all services. A visit may include several services. Include buttons for Calculate, Clear, Print and Exit. (Part 2) Allow for sales to additional patrons, include buttons for Next Patron and Summary. When the receptionist clicks the Summary button, display in a summary message box the number of clients and the total dollar value for all services rendered. For Next patron, confirm that the user wants to clear the totals for the current customer.
Once I’m done with part 1, I don’t know how to code part 2. Can some explain this is easy terms please? Thank you.
Here is my code so far:
Public Class Form1
' Declare Constants.
Const PERMANENT_MAKEUP As Decimal = 200D
Const MAKEOVER As Decimal = 125D
Const HAIR_STYLING As Decimal = 60D
Const MANICURE As Decimal = 35D
Const TEN_PERCENT As Decimal = 0.1
Const TWENTY_PERCENT As Decimal = 0.2
Dim TOTAL_DUE As Decimal
'Code for Button Calculate (Double-Click on the Button in Design view to get this Event handler)
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateButton.Click
Dim servicePrice As Decimal
Dim PricePerService As Decimal
If MakeoverCheckBox.Checked Then
servicePrice = MAKEOVER
ElseIf HairStylingCheckBox.Checked Then
servicePrice = HAIR_STYLING
ElseIf ManicureCheckBox.Checked Then
servicePrice = MANICURE
ElseIf PermanentMakeupCheckBox.Checked Then
servicePrice = PERMANENT_MAKEUP
End If
If DiscountComboBox.SelectedItem = "None" Then
PricePerService = servicePrice
ElseIf DiscountComboBox.SelectedItem = "10 percent" Then
PricePerService = servicePrice - (servicePrice * TEN_PERCENT)
ElseIf DiscountComboBox.SelectedItem = "20 percent" Then
PricePerService = servicePrice - (servicePrice * TWENTY_PERCENT)
End If
TOTAL_DUE = PricePerService
ServicesMaskedTextBox.Text = PricePerService.ToString("C")
TotalDueMaskedTextBox.Text = TOTAL_DUE.ToString("C")
End Sub
'Code for Button Clear (Double-Click on the Button in Design view to get this Event handler)
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButton.Click
MakeoverCheckBox.Checked = True
DiscountComboBox.SelectedItem = "None"
ServicesMaskedTextBox.Text = String.Empty
TotalDueMaskedTextBox.Text = String.Empty
End Sub
'Code for Button Print (Double-Click on the Button in Design view to get this Event handler)
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintButton.Click
PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
PrintForm1.Print()
End Sub
'Code for Button Exit (Double-Click on the Button in Design view to get this Event handler)
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
Me.Close()
End Sub
Private Sub HairStylingCheckBox_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles HairStylingCheckBox.CheckedChanged
End Sub
End Class
Once I’m done with part 1, I don’t know how to code part 2. Can some explain this is easy terms please? Thank you.
Here is my code so far:
Public Class Form1
' Declare Constants.
Const PERMANENT_MAKEUP As Decimal = 200D
Const MAKEOVER As Decimal = 125D
Const HAIR_STYLING As Decimal = 60D
Const MANICURE As Decimal = 35D
Const TEN_PERCENT As Decimal = 0.1
Const TWENTY_PERCENT As Decimal = 0.2
Dim TOTAL_DUE As Decimal
'Code for Button Calculate (Double-Click on the Button in Design view to get this Event handler)
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateButton.Click
Dim servicePrice As Decimal
Dim PricePerService As Decimal
If MakeoverCheckBox.Checked Then
servicePrice = MAKEOVER
ElseIf HairStylingCheckBox.Checked Then
servicePrice = HAIR_STYLING
ElseIf ManicureCheckBox.Checked Then
servicePrice = MANICURE
ElseIf PermanentMakeupCheckBox.Checked Then
servicePrice = PERMANENT_MAKEUP
End If
If DiscountComboBox.SelectedItem = "None" Then
PricePerService = servicePrice
ElseIf DiscountComboBox.SelectedItem = "10 percent" Then
PricePerService = servicePrice - (servicePrice * TEN_PERCENT)
ElseIf DiscountComboBox.SelectedItem = "20 percent" Then
PricePerService = servicePrice - (servicePrice * TWENTY_PERCENT)
End If
TOTAL_DUE = PricePerService
ServicesMaskedTextBox.Text = PricePerService.ToString("C")
TotalDueMaskedTextBox.Text = TOTAL_DUE.ToString("C")
End Sub
'Code for Button Clear (Double-Click on the Button in Design view to get this Event handler)
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButton.Click
MakeoverCheckBox.Checked = True
DiscountComboBox.SelectedItem = "None"
ServicesMaskedTextBox.Text = String.Empty
TotalDueMaskedTextBox.Text = String.Empty
End Sub
'Code for Button Print (Double-Click on the Button in Design view to get this Event handler)
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintButton.Click
PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
PrintForm1.Print()
End Sub
'Code for Button Exit (Double-Click on the Button in Design view to get this Event handler)
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
Me.Close()
End Sub
Private Sub HairStylingCheckBox_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles HairStylingCheckBox.CheckedChanged
End Sub
End Class
- Lisa
- Reputation: 0
- Posts: 1
- Joined: Sun Oct 02, 2011 1:36 pm
- Highscores: 0
- Arcade winning challenges: 0
0
Re: Help please. Thank you.
Hi there mate ;D
Ok so the code you wrote did not contain to many mistakes. The only problem with it is the fact that the button event handling lines are different at start and at the end.
Eg.
Private Sub btnCalculate_Click_1(sender As System.Object, e As System.EventArgs) Handles btnCalculate.Click
yours was btnCalculate_Click_1 and at the end Handles ButtonCalculate.
Other thing was when you press Clear it was ticking manicure checkbox but was not doing anything with other checkboxes so if while running you picked permanent makeup it would stay even after pressing clear button.
I fixed your code:
Public Class PermanentMakeup
' Declare Constants.
Const PERMANENT_MAKEUP As Decimal = 200D
Const MAKEOVER As Decimal = 125D
Const HAIR_STYLING As Decimal = 60D
Const MANICURE As Decimal = 35D
Const TEN_PERCENT As Decimal = 0.1
Const TWENTY_PERCENT As Decimal = 0.2
Dim TOTAL_DUE As Decimal
'Code for Button Clear (Double-Click on the Button in Design view to get this Event handler)
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
If MakeOverCheckBox.Checked Then
MakeOverCheckBox.Checked = False
ElseIf HairStylingCheckBox.Checked Then
HairStylingCheckBox.Checked = False
ElseIf ManicureCheckBox.Checked Then
ManicureCheckBox.Checked = False
ElseIf PermanentMakeupCheckBox.Checked Then
PermanentMakeupCheckBox.Checked = False
End If
DiscountComboBox.SelectedItem = "None"
ServicesMaskedTextBox.Text = String.Empty
TotalDueMaskedTextBox.Text = String.Empty
End Sub
'Code for Button Print (Double-Click on the Button in Design view to get this Event handler)
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
PrintForm1.Print()
End Sub
'Code for Button Exit (Double-Click on the Button in Design view to get this Event handler)
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub HairStylingCheckBox_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles HairStylingCheckBox.CheckedChanged
End Sub
Private Shared Function Checked() As Boolean
Throw New NotImplementedException
End Function
Private Sub btnCalculate_Click_1(sender As System.Object, e As System.EventArgs) Handles btnCalculate.Click
Dim servicePrice As Decimal
Dim PricePerService As Decimal
If MakeOverCheckBox.Checked Then
servicePrice = MAKEOVER
ElseIf HairStylingCheckBox.Checked Then
servicePrice = HAIR_STYLING
ElseIf ManicureCheckBox.Checked Then
servicePrice = MANICURE
ElseIf PermanentMakeupCheckBox.Checked Then
servicePrice = PERMANENT_MAKEUP
End If
If DiscountComboBox.SelectedItem = "None" Then
PricePerService = servicePrice
ElseIf DiscountComboBox.SelectedItem = "10 percent" Then
PricePerService = servicePrice - (servicePrice * TEN_PERCENT)
ElseIf DiscountComboBox.SelectedItem = "20 percent" Then
PricePerService = servicePrice - (servicePrice * TWENTY_PERCENT)
End If
TOTAL_DUE = PricePerService
ServicesMaskedTextBox.Text = PricePerService.ToString("C")
TotalDueMaskedTextBox.Text = TOTAL_DUE.ToString("C")
End Sub
End Class
Didnt add the part 2 coding as it is your project ;P
Good luck with it
Ok so the code you wrote did not contain to many mistakes. The only problem with it is the fact that the button event handling lines are different at start and at the end.
Eg.
Private Sub btnCalculate_Click_1(sender As System.Object, e As System.EventArgs) Handles btnCalculate.Click
yours was btnCalculate_Click_1 and at the end Handles ButtonCalculate.
Other thing was when you press Clear it was ticking manicure checkbox but was not doing anything with other checkboxes so if while running you picked permanent makeup it would stay even after pressing clear button.
I fixed your code:
Public Class PermanentMakeup
' Declare Constants.
Const PERMANENT_MAKEUP As Decimal = 200D
Const MAKEOVER As Decimal = 125D
Const HAIR_STYLING As Decimal = 60D
Const MANICURE As Decimal = 35D
Const TEN_PERCENT As Decimal = 0.1
Const TWENTY_PERCENT As Decimal = 0.2
Dim TOTAL_DUE As Decimal
'Code for Button Clear (Double-Click on the Button in Design view to get this Event handler)
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
If MakeOverCheckBox.Checked Then
MakeOverCheckBox.Checked = False
ElseIf HairStylingCheckBox.Checked Then
HairStylingCheckBox.Checked = False
ElseIf ManicureCheckBox.Checked Then
ManicureCheckBox.Checked = False
ElseIf PermanentMakeupCheckBox.Checked Then
PermanentMakeupCheckBox.Checked = False
End If
DiscountComboBox.SelectedItem = "None"
ServicesMaskedTextBox.Text = String.Empty
TotalDueMaskedTextBox.Text = String.Empty
End Sub
'Code for Button Print (Double-Click on the Button in Design view to get this Event handler)
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
PrintForm1.Print()
End Sub
'Code for Button Exit (Double-Click on the Button in Design view to get this Event handler)
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub HairStylingCheckBox_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles HairStylingCheckBox.CheckedChanged
End Sub
Private Shared Function Checked() As Boolean
Throw New NotImplementedException
End Function
Private Sub btnCalculate_Click_1(sender As System.Object, e As System.EventArgs) Handles btnCalculate.Click
Dim servicePrice As Decimal
Dim PricePerService As Decimal
If MakeOverCheckBox.Checked Then
servicePrice = MAKEOVER
ElseIf HairStylingCheckBox.Checked Then
servicePrice = HAIR_STYLING
ElseIf ManicureCheckBox.Checked Then
servicePrice = MANICURE
ElseIf PermanentMakeupCheckBox.Checked Then
servicePrice = PERMANENT_MAKEUP
End If
If DiscountComboBox.SelectedItem = "None" Then
PricePerService = servicePrice
ElseIf DiscountComboBox.SelectedItem = "10 percent" Then
PricePerService = servicePrice - (servicePrice * TEN_PERCENT)
ElseIf DiscountComboBox.SelectedItem = "20 percent" Then
PricePerService = servicePrice - (servicePrice * TWENTY_PERCENT)
End If
TOTAL_DUE = PricePerService
ServicesMaskedTextBox.Text = PricePerService.ToString("C")
TotalDueMaskedTextBox.Text = TOTAL_DUE.ToString("C")
End Sub
End Class
Didnt add the part 2 coding as it is your project ;P
Good luck with it
- Ciiure
- Reputation: 1
- Posts: 5
- Joined: Fri Nov 18, 2011 8:45 pm
- Highscores: 0
- Arcade winning challenges: 0
|
|