Shipping Cost Extra - vb.net

Am having problem with shipping extra cost in vb 2010 , The question is to calculate the extra handling charge of $5.00 per part for an oversize container (the Oversize Container CheckBox is checked). Below is the code i have worked on for the shipping rate . I have define oversize as constant but i cant get it to work
What we are told to do is to make sure when the oversizedcheckbox is checked it should calculate the oversize amount which is $5 per unit and it should be added to any shipping charges that has been selected . In my case i have 4 shipping which is
ups $7 per unit , us postal air $8.5 per unit , fedex ground $9.2 per unit and fedex air $12 per unit
Public Class Lab5
'ship mode constants
Const U_P_S_DECIMAL As Decimal = 7D
Const FED_EX_AIR_DECIMAL As Decimal = 12D
Const FED_EX_GROUND_DECIMAL As Decimal = 9.25D
Const US_POSTRAL_AIR_DECIMAL As Decimal = 8.5D
Const SALES_TAX_RATE_SINGLE As Single = 0.1 '10 Percent Rate
'declear module-level variables
Private TotalQuantityInteger As Integer
Private TotalSalesDecimal As Decimal
Private Sub ComputeButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComputeButton.Click, ComputeToolStripMenuItem.Click
Try
Dim TotalCostDecimal, ShippingCostDecimal, SalesTaxDecimal, OversizeDecimal, TotalDueDecimal As Decimal
'Declare variables and convert value from textbox controls to memory
Dim PriceDecimal As Decimal = Decimal.Parse(PriceTextBox.Text, Globalization.NumberStyles.Currency)
Dim QuantityInteger As Integer = Integer.Parse(QuantityTextBox.Text, Globalization.NumberStyles.Number)
'Process - Compute values
'Subtotal = price times the quantity of books
TotalCostDecimal = PriceDecimal * QuantityInteger
'Sales tex = sales tax rate times the subtotal minus discount amount
If RetailCheckBox.Checked Then
SalesTaxDecimal = Decimal.Round(Convert.ToDecimal(TotalCostDecimal * SALES_TAX_RATE_SINGLE), 2)
End If
If CustomerIDMaskedTextBox.MaskCompleted = False Then
'incomplete telephone number
MessageBox.Show("Incomplete or missing CustomerID", "CustomerID Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
CustomerIDMaskedTextBox.Focus()
CustomerIDMaskedTextBox.SelectAll()
ElseIf NameTextBox.Text.Trim = String.Empty Then
'Customer name is required
MessageBox.Show("Customer Name is required", "Customer Name Missing Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
NameTextBox.Focus()
NameTextBox.SelectAll()
ElseIf StateTextBox.Text.Trim = String.Empty Then
'Shipping address required
MessageBox.Show("State is required", "State Missing Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
StateTextBox.Focus()
StateTextBox.SelectAll()
ElseIf PartTextBox.Text.Trim = String.Empty Then
'Missing Part Number Required
MessageBox.Show("Part Number is missing", "Part Number Missing Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
PartTextBox.Focus()
PartTextBox.SelectAll()
ElseIf DescriptionTextBox.Text.Trim = String.Empty Then
'Description is Required
MessageBox.Show("Product Description is missing", "Product Description Missing Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
DescriptionTextBox.Focus()
DescriptionTextBox.SelectAll()
ElseIf IsNumeric(PriceTextBox.Text) = False Then
'the purchase price textbox must contain a numeric value
MessageBox.Show("Price must contain a numeric value", "Price Not Numeric Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
PriceTextBox.Focus()
PriceTextBox.SelectAll()
ElseIf IsNumeric(QuantityTextBox.Text) = False Then
'the Quantity purchased Testbox must contain a numeric value
MessageBox.Show("Quantity must be input", "Quantity Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
QuantityTextBox.Focus()
QuantityTextBox.SelectAll()
ElseIf Decimal.Parse(QuantityTextBox.Text, Globalization.NumberStyles.Number) < 0 Then
'the quantity purchased must be greater than zero
MessageBox.Show("The quantity must be greater than zero", "Quantity Purchased not greater than zero Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
End If
'Shipping cost
If UPSRadioButton.Checked Then 'compute the shipping cost
ShippingCostDecimal = U_P_S_DECIMAL * QuantityInteger
ElseIf FedExAirRadioButton.Checked Then
ShippingCostDecimal = FED_EX_AIR_DECIMAL * QuantityInteger
ElseIf FedExGroundRadioButton.Checked Then
ShippingCostDecimal = FED_EX_GROUND_DECIMAL * QuantityInteger
ElseIf USPostalAirRadioButton.Checked Then
ShippingCostDecimal = US_POSTRAL_AIR_DECIMAL * QuantityInteger
End If
'Compute TotalDue
TotalDueDecimal = SalesTaxDecimal + ShippingCostDecimal + TotalCostDecimal
'Data computed output
SubtotalTextBox.Text = TotalCostDecimal.ToString("C")
TotalDueTextBox.Text = TotalDueDecimal.ToString("C2")
SalesTaxTextBox.Text = SalesTaxDecimal.ToString("N")
ShippingCostTextBox.Text = ShippingCostDecimal.ToString("N")
'Accumulate total sales and total books sold
TotalQuantityInteger += QuantityInteger
TotalSalesDecimal += TotalDueDecimal
Catch ex As Exception
MessageBox.Show("unexpected error", "Compute Button Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub

As mentioned in my comment....
You say you need to add an oversize rate of $5 but this line
OversizeDecimal = ShippingCostDecimal * OVERSIZE_RATE_DECIMAL
seem to be multiplying by 5
Try
OversizeDecimal = ShippingCostDecimal + (OVERSIZE_RATE_DECIMAL * QuantityInteger)

I finally figure it out myself
Public Class Lab5
'ship mode constants
Const U_P_S_DECIMAL As Decimal = 7D
Const FED_EX_AIR_DECIMAL As Decimal = 12D
Const FED_EX_GROUND_DECIMAL As Decimal = 9.25D
Const US_POSTRAL_AIR_DECIMAL As Decimal = 8.5D
Const OVERSIZE_RATE_DECIMAL As Decimal = 5D
Const SALES_TAX_RATE_SINGLE As Single = 0.1 '10 Percent Rate
'Oversized Handling Charges
If OversizedCheckBox.Checked Then
ShippingCostDecimal = QuantityInteger * (OVERSIZE_RATE_DECIMAL + U_P_S_DECIMAL)
ElseIf OversizedCheckBox.Checked Then
ShippingCostDecimal = QuantityInteger * (OVERSIZE_RATE_DECIMAL + FED_EX_AIR_DECIMAL)
ElseIf OversizedCheckBox.Checked Then
ShippingCostDecimal = QuantityInteger * (OVERSIZE_RATE_DECIMAL + FED_EX_GROUND_DECIMAL)
ElseIf OversizedCheckBox.Checked Then
ShippingCostDecimal = QuantityInteger * (OVERSIZE_RATE_DECIMAL + US_POSTRAL_AIR_DECIMAL)
End If

Related

Exception Using If Else

I have a task to make a calculation of selling price and cost value.
I don't know have any idea to make a good coding for exception.
Private Sub ButtonCalculate_Click(sender As Object, e As EventArgs) Handles ButtonCalculate.Click
Dim SellingPrice As Double
Dim CostValue As Double
Dim Commission As Double
Dim CommissionRate As Double = 0.2
If Me.TextBoxSellingPrice.Text <> "" Or Me.TextBoxCostValue.Text <> "" Then
Try
SellingPrice = Double.Parse(TextBoxSellingPrice.Text)
CostValue = Double.Parse(TextBoxCostValue.Text)
'Calculation
Commission = CommissionRate * (SellingPrice - CostValue)
'Display
Me.TextBoxDisplay.Text = Me.TextBoxName.Text
Me.TextBoxCommission.Text = "RM" + Commission.ToString("F2")
Catch
MessageBox.Show("Wrong Input", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Else
MessageBox.Show("Please fill your data completely", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
Output:
Figure 1
Using exception handling to check that data is correct isn't really the best practice. For a start, the performance of Try..Catch blocks is pretty poor compared to just using If..Then..Endif as there is a fair amount of stuff happening in the background with exceptions. In your case it wont make a major difference, but if the Try..Catch..End Try is in a loop, your program can take quite a performance hit.
There is little else to do other than to write some If..End If statements to validate your input data .. As other commenters had stated, using .TryParse is an exellent way to start things off ..
If Not Double.TryParse(TextBoxSellingPrice.Text, SellingPrice) Or Not Double.TryParse(TextBoxCostValue.Text, CostValue) Then
MessageBox.Show("Invalid input. Please enter positive numbers only")
Exit Sub
End If
If SellingPrice < CostValue Then
MessageBox.Show("Selling Price must be greater than cost")
Exit Sub
End If
If Not SellingPrice > 0 Or Not CostValue > 0 Then
MessageBox.Show("Selling price and cost must be >0")
Exit Sub
End If
'Calculation
Commission = CommissionRate * (SellingPrice - CostValue)
'Display
Me.TextBoxDisplay.Text = Me.TextBoxName.Text
Me.TextBoxCommission.Text = "RM" + Commission.ToString("F2")
You could also have a look at the ErrorProvider component

Whats wrong with my error trapping function?

I have a program for buying shirts, I'm changing it so the error trapping happens through a function, so I deleted my previous error trapping, created the function, and tried it out. But somewhere I must of screwed up, because it's not working properly. I was following step by step the video guide from my class, but I can't find where I went wrong. I've been trying to figure it out for a few hours now but have gotten nowhere. Any help would be appreciated. What's happening is when I click Calculate or Next Sale, it will always give me my error message "Please enter a valid number" I've tried entering 0, 1, 25, 50, 51, 55, and 5a. It should give me an error message for 5a saying "Please enter a valid number", because it's not numeric. And it should give me the error message "Please enter a number from 1 to 50" for 0, 51, and 55. I couldn't even get that error message to work because every number I entered gave the "Please enter a valid number" error message. Where did I go wrong? Help me find the error please.
Here is the function:
Private Function CheckTextBox(ByVal TextBoxName As TextBox, ByVal Min As Single, ByVal Max As Single, ByVal IntCheck As Boolean) As Boolean
If Not IsNumeric(TextBoxName) Then
MessageBox.Show("Please enter a valid number", "Error", MessageBoxButtons.OK)
TextBoxName.Text = ""
TextBoxName.Focus()
Exit Function
End If
If Val(TextBoxName.Text) < Min Or Val(TextBoxName.Text) > Max Then
MessageBox.Show("Please enter a number from " & Min & " to " & Max, "Error", MessageBoxButtons.OK)
TextBoxName.Text = ""
TextBoxName.Focus()
Exit Function
End If
If IntCheck Then
If Val(TextBoxName.Text) <> Int(TextBoxName.Text) Then
MessageBox.Show("Please enter a whole number", "Error", MessageBoxButtons.OK)
TextBoxName.Text = ""
TextBoxName.Focus()
Exit Function
End If
End If
Return True
End Function
Here is the code for the Calculate button:
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
'Local Variable Declaration Section
Dim sngSalesTax As Single
Dim sngOrderTotal As Single
Dim intQuantity As Integer
Dim sngItemTotal As Single
'Data Input Section
If msngShippingCost = -1 Then
MessageBox.Show("Please choose a shipping method", "Error", MessageBoxButtons.OK) 'Displays an error messsage when no shipping method is chosen
Exit Sub 'Terminates the click event to allow shipping method to be chosen first
End If
If CheckTextBox(txtQuantity, 1, 50, True) = False Then
Exit Sub
End If
intQuantity = CInt(txtQuantity.Text) 'not sure if this line is needed?
'Calculation Section
sngItemTotal = msngItemPrice * intQuantity
msngSubtotal += sngItemTotal 'Calculates the subtotal
sngSalesTax = msngSubtotal * csngSalesTaxRate 'Calculates Sales Tax based on the sales tax rate constant
sngOrderTotal = msngSubtotal + sngSalesTax + msngShippingCost 'Calculates total for the sale
mintOrdersPlacedToday = mintOrdersPlacedToday + 1 'Calculates the number of orders placed today, adds one to the previous number
msngTotalOfOrdersToday = msngTotalOfOrdersToday + sngOrderTotal 'Calculates the Total of all the orders placed today
'Output section
lblShowSubTotal.Text = FormatCurrency(msngSubtotal) 'Displays the Sub Total
lblShowSalesTax.Text = FormatCurrency(sngSalesTax) 'Displays the Sales Tax
lblShowOrderTotal.Text = FormatCurrency(sngOrderTotal) 'Displays the Order Total
lblShowOrdersPlacedToday.Text = mintOrdersPlacedToday 'Displays the Orders placed today
lblShowTotalOfOrders.Text = FormatCurrency(msngTotalOfOrdersToday) 'Displays the Total of the Orders placed today
lblShowShippingCost.Text = FormatCurrency(msngShippingCost) 'Displays the total of the shipping cost
End Sub
And here is the code for the next item button:
Private Sub btnNextItem_Click(Sender As Object, e As EventArgs) Handles btnNextItem.Click
'Local Variable Declaration Section
Dim sngSalesTax As Single
Dim intQuantity As Integer
Dim sngItemTotal As Single
'Data Input Section
If CheckTextBox(txtQuantity, 1, 50, True) = False Then 'Uses the function to error trap exits sub if functions returns as false
Exit Sub
End If
intQuantity = CInt(txtQuantity.Text)
'Calculation Section
sngItemTotal = msngItemPrice * intQuantity 'Calculates item total
msngSubtotal += sngItemTotal 'Calculates the subtotal
sngSalesTax = msngSubtotal * csngSalesTaxRate 'Calculates Sales Tax based on the sales tax rate constant
'Output section
lblShowShippingCost.Text = ""
lblShowOrderTotal.Text = ""
lblShowSubTotal.Text = FormatCurrency(msngSubtotal) 'Displays the Sub Total
lblShowSalesTax.Text = FormatCurrency(sngSalesTax) 'Displays the Sales Tax
End Sub

Visual Basic code- Having trouble displaying the Total. New to VB

I have to write a program that calculates costs for a catering company. i have that part down, but whats stumping me is I have trouble displaying the total. What also is stumping me is that i have to make a summary button that adds everything up into a grand total from the previous calculations and display it in a message box. displaying and calculations aren't really my issues, but getting the data to calculate is.
Thank you
HERE's the code.
Const decPRIME_RIB As Decimal = 25.95D
Const decCHICKEN As Decimal = 18.95D
Const decPASTA As Decimal = 12.95D
Const decOPEN_BAR As Decimal = 25D
Const decWINE As Decimal = 8D
Const decBEER As Decimal = 10D
'Declare module-level variables for summary information.
Private TotalDollar As Decimal
Private AmountDue As Decimal
Private SubTotalDecimal As Decimal
Private TotalDecimal As Decimal
Private Guest As Integer
Private EventCountInteger As Integer
Private Sub CalcBtn_Click(sender As Object, e As EventArgs) Handles CalcBtn.Click
' Calculate and display the current amounts and add to totals.
Dim FoodChoiceDecimal As Decimal
Dim OpenBarDecimal As Decimal
Dim WineDecimal As Decimal
Dim DrinksDecimal As Decimal
' Find the price.
If PrimeRB.Checked Then
FoodChoiceDecimal = decPRIME_RIB
ElseIf ChickRB.Checked Then
FoodChoiceDecimal = decCHICKEN
ElseIf PastaRB.Checked Then
FoodChoiceDecimal = decPASTA
End If
If OpenCB.Checked Then
OpenBarDecimal = decOPEN_BAR
End If
If WineCB.Checked Then
WineDecimal = decWINE
End If
'Multiply price by number of guest and drink selection.
Try
DrinksDecimal = (OpenBarDecimal + WineDecimal)
AmountDue = (FoodChoiceDecimal + DrinksDecimal) * Guest
' display totals.
TotalLbl.Text = TotalLbl.ToString("C")
' Allow change for new event.
OpenCB.Enabled = False
WineCB.Enabled = False
ClearBtn.Enabled = True
SummaryBtn.Enabled = True
Catch NumberOfGuestsException As FormatException
MessageBox.Show("Number of Guests must be Numeric", _
"Data entry Error", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
End Try
End Sub
Private Sub SummaryBtn_Click(sender As Object, e As EventArgs) Handles SummaryBtn.Click
' Calculate total dollar amounts and number of events.
Dim MessageString As String
If EventCountInteger > 0 Then
' Calculate the summary sales totals.
TotalDollar += AmountDue
'Concatenate the message string.
MessageString = "Number of Events:" & EventCountInteger.ToString() _
& Environment.NewLine & Environment.NewLine _
& "Total Sales: " & TotalDollar.ToString("C")
MessageBox.Show(MessageString, "Sales Summary", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
End If

VB.NET - Accumulating Numbers and Calculating Average

I have started over and everything is working as intended except for 2 of the accumulating totals, the calculation is not working the way I need it to. Instead of adding previous sales to the total it tacks the new sale on the end...
for example: I input 1 Snowboard and 1 Snowboard with Boots, this works, 1 is shown in the summary for both Snowboards and Snowboards with Boots. However when I try to input again in order to keep a running total of sales I have a problem, I enter 1 Snowboard and 1 Snowboard with Boots, and the summaries show 11 rather than 2. Why does this happen?
' Declare module-level variables and constants.
Private SnowBoardsSold, BootsSold, SaleCount As Integer
Private ItemsSold As Integer
Private TotalSales As Decimal
Const SNOWBOARD_RATE As Decimal = 20D
Const BOOTS_RATE As Decimal = 30D
Private Sub CalculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateButton.Click
' Calculate the prices
Dim SnowBoards, Boots As Integer
Dim SnowBoardSale, BootsSale, ThisSale, AverageSalesEver As Decimal
Try
' Convert the Snowboard input to numeric variable.
SnowBoards = Integer.Parse(SnowboardsTextBox.Text)
Try
' Convert Boots if Snowboard was successful.
Boots = Integer.Parse(WithBootsTextBox.Text)
' Calculate values for sale.
SnowBoardSale = SnowBoards * SNOWBOARD_RATE
BootsSale = Boots * BOOTS_RATE
ThisSale = SnowBoardSale + BootsSale
' Calculate summary values.
TotalSales += ThisSale
BootsSold += BootsSale
SnowBoardsSold += SnowBoardSale
SaleCount += 1
AverageSalesEver = TotalSales / SaleCount
' Format and display prices for the sale.
SnowBoardsPriceTextBox.Text = SnowBoardSale.ToString("c")
BootsPriceTextBox.Text = BootsSale.ToString("c")
TotalPriceTextBox.Text = ThisSale.ToString("c")
' Format and display values for the summary.
SnowBoardRentalTextBox.Text += SnowBoards.ToString()
BootsRentalTextBox.Text += Boots.ToString()
TotalChargesTextBox.Text = TotalSales.ToString("c")
AverageChargeTextBox.Text = AverageSalesEver.ToString("c")
Catch BootsException As FormatException
' Handle a Boots exception.
MessageBox.Show("Please enter numbers.", "Data Entry Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
With WithBootsTextBox
.Focus()
.SelectAll()
End With
End Try
Catch SnowBoardsException As FormatException
' Handle a SnowBoard exception.
MessageBox.Show("Please enter numbers.", "Data Entry Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
With SnowboardsTextBox
.Focus()
.SelectAll()
End With
Catch AnException As Exception
'Handle any other exception.
MessageBox.Show("Error: " & AnException.Message)
End Try
End Sub
First, you might want to change the way you grab the numbers:
'Convert snowboard input value to numeric variable.
SnowboardInteger = Integer.Parse(SnowboardsTextBox.Text)
to:
Dim SnowboardInteger As Integer
If TryParse.Integer(SnowboardsTextBox.Text, SnowboardInteger) = False then
' if it parses, SnowboardInteger will have the value,
'else the function returns false
MessageBox.Show("Please enter numbers")
End if
Also, you are parsing the textboxes twice. Once in the declaration then right after. This doesnt look right:
SnowboardSaleCountInteger += 1
WithBootsSaleCountInteger += 1
TotalSaleCountInteger += TotalChargesSumInteger ' ?????
AverageChargeInteger = TotalChargesSumInteger / TotalSaleCountInteger
Adding 'charges' to a 'counter' doesnt seem right. If you want the avg shouldnt it be:
TotalSaleCountInteger = SnowboardSaleCountInteger + WithBootsSaleCountInteger
If you want fractions such as 'xx.yy' in the result, AverageChargeInteger should be a Double or Decimal, unless whole dollars are ok for the assignment.
If you need to accumulate from previous clicks, then you need to move some declarations out of the procedure up by SnowboardSumInteger, WithBootsSumInteger so they can accumulate. As it is, WithBootsSaleCountInteger, TotalSaleCountInteger dont do anything and are always 1. I wonder if as a 'SaleCounter' they shouldnt increase by the value in the textbox rather than just 1 (dont have the assignment in front of me).
One more thing you might need to do is here:
SnowboardPriceInteger = SnowboardInteger * SNOWBOARD_RENTAL_RATE
WithBootsPriceInteger = WithBootsInteger * WITH_BOOTS_RENTAL_RATE
TotalPriceInteger = SnowboardPriceInteger + WithBootsPriceInteger
Your constants are Decimal (SNOWBOARD_RENTAL_RATE) so, the result of the calc has to go into a Decimal var, but SnowboardPriceInteger and the other are not. An integer cannot store a fractional result from the multiplication or division.
something like:
' sales accumulators
Private TotalSales As Decimal = 0
Private ItemsSold As Integer = 0
Click Event:
' this sale:
Dim Snowboards As Integer
Dim Boots As Integer
' get the values from the text boxes, then:
Dim SnowBoardSale As Decimal = (SnowBoards * SnowBoardRate)
Dim BootsSale As Decimal = (Boots * BootsRate)
Dim ThisSale As Decimal = SnowBoardSale + BootsSale
' update accumulators
TotalSales += ThisSale
ItemsSold += (Boots + Snowboards)
' calc the average
Dim AverageSalesEver AS Decimal = TotalSales / ItemsSold
' Display results in textboxes
'(this exercise is left to the student ;) )
HTH
I think you just confused yourself with too many variables and ones left over from old attempts.

VB.NET Button Event Issue

I am having problem with a button the code of my button is.
Private Sub btnCalculateCosts_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnCalculateCosts.Click
it handles:
' This Calculate Costs button click event handler edits the
' registration(costs) form to ensure it contains valid data.
' Then, after passing control to the business class, it
' displays the registration cost.
Dim objCourse As Course
Dim objCourseCostsFile As Course
Dim InputError As Boolean = False
' Is student ID entered properly
If Me.txtCorporateID.MaskFull = False Then
MessageBox.Show("Enter your Corporate ID in the Corporate ID box", "Error")
Me.txtCorporateID.Clear()
Me.txtCorporateID.Focus()
InputError = True
' Is student name entered properly
ElseIf Me.txtFirstName.TextLength < 1 Or _
Me.txtFirstName.Text < "A" Then
MessageBox.Show("Please enter your first name in the First Name box", "Error")
Me.txtFirstName.Clear()
Me.txtFirstName.Focus()
InputError = True
' Is number of units entered properly
ElseIf Me.txtLastName.TextLength < 1 Or _
Me.txtLastName.Text < "A" Then
MessageBox.Show("Please enter your last name in the Last Name box", "Error")
Me.txtLastName.Clear()
Me.txtLastName.Focus()
InputError = True
' Is number of units entered properly
ElseIf Not IsNumeric(Me.txtNumberOfDays.Text) Then
MessageBox.Show("Enter the units in the Number of Units box", "Error")
Me.txtNumberOfDays.Clear()
Me.txtNumberOfDays.Focus()
InputError = True
' Has 1-4 units been entered
ElseIf Convert.ToInt32(Me.txtNumberOfDays.Text) < 1 _
Or Convert.ToInt32(Me.txtNumberOfDays.Text) > 4 Then
MessageBox.Show("Units must be 1 - 4", "Error")
Me.txtNumberOfDays.Clear()
Me.txtNumberOfDays.Focus()
InputError = True
End If
' If no input error, process the registration costs
If Not InputError Then
If Me.radPreConferenceCourse.Checked = False Then
objCourse = New Course(txtCorporateID.Text, txtFirstName.Text, txtLastName.Text, txtNumberOfDays.Text)
Me.lblCosts.Visible = True
Me.lblCosts.Text = "Total Conference Costs Are: " & (objCourse.ComputeCosts()).ToString("C2")
Else
objCourse = New Course(txtCorporateID.Text, txtFirstName.Text, txtLastName.Text, txtNumberOfDays.Text, g)
Me.lblCosts.Visible = True
Me.lblCosts.Text = "Total Conference Costs Are: " & (objCourse.ComputeCosts()).ToString("C2")
....
Receiving the error:
Handles clause requires a WithEvents variable defined in the
containing type or one of its base types.
Where is btnCalculateCosts defined? – SLaks 14 hours ago