Brian Gagnon
New member
This is what I have so far:
Private Sub AddThisItemButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddThisItemButton.Click
' This button adds the item to the summary and when clicked it also validates the quantity, weight, and price. It also
' disables the Customer Group Box.
CustomerGroupBox.Enabled = False
Dim QuantityInteger As Integer
Dim WeightDecimal As Decimal
Dim PriceDecimal As Decimal
Try
' Converts Quantity to numeric variable.
QuantityInteger = Integer.Parse(QuantityTextBox.Text)
Try
' Converts Weight to numeric variable.
WeightDecimal = Decimal.Parse(WeightTextBox.Text)
Try
' Converts Price to numeric variable.
PriceDecimal = Decimal.Parse(PriceTextBox.Text)
' Calculates Dollar Amount Due.
ItemAmountDouble = PriceDecimal * QuantityInteger
DollarAmountDueDouble += ItemAmountDouble
DollarAmountDueTextBox.Text = DollarAmountDueDouble.ToString("C")
' Calculates Sales Tax Only if the Customer is Shipping to California.
If StateTextBox.Text = "CA" Then
SalesTaxDouble = DollarAmountDueDouble * Tax_Rate_Decimal
SalesTaxTextBox.Text = SalesTaxDouble.ToString("C")
Else
SalesTaxDouble = 0.0
SalesTaxTextBox.Text = SalesTaxDouble.ToString("C")
End If
' Calculates Shipping and Handling Part A
PartWeightDecimal = QuantityInteger * WeightDecimal
PartWeightNewDecimal += PartWeightDecimal
Catch QuantityException As FormatException
' Handles a quantity exception
MessageBox.Show("The quantity must be a numeric. (Whole number)", "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
With QuantityTextBox
.Focus()
.SelectAll()
End With
End Try
Catch WeightException As FormatException
' Handles a weight exception.
MessageBox.Show("The weight must be a numeric.", "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
With WeightTextBox
.Focus()
.SelectAll()
End With
End Try
Catch PriceException As FormatException
' Handles a price exception.
MessageBox.Show("The price must be a numeric.(Dollars and cents)", "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
With PriceTextBox
.Focus()
.SelectAll()
End With
End Try
With DescriptionTextBox
.Focus()
.SelectAll()
End With
End Sub
When it runs the only catch that works is the only called PriceException. No idea why it isn't working. Can anyone help? Thanks in advance.
Private Sub AddThisItemButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddThisItemButton.Click
' This button adds the item to the summary and when clicked it also validates the quantity, weight, and price. It also
' disables the Customer Group Box.
CustomerGroupBox.Enabled = False
Dim QuantityInteger As Integer
Dim WeightDecimal As Decimal
Dim PriceDecimal As Decimal
Try
' Converts Quantity to numeric variable.
QuantityInteger = Integer.Parse(QuantityTextBox.Text)
Try
' Converts Weight to numeric variable.
WeightDecimal = Decimal.Parse(WeightTextBox.Text)
Try
' Converts Price to numeric variable.
PriceDecimal = Decimal.Parse(PriceTextBox.Text)
' Calculates Dollar Amount Due.
ItemAmountDouble = PriceDecimal * QuantityInteger
DollarAmountDueDouble += ItemAmountDouble
DollarAmountDueTextBox.Text = DollarAmountDueDouble.ToString("C")
' Calculates Sales Tax Only if the Customer is Shipping to California.
If StateTextBox.Text = "CA" Then
SalesTaxDouble = DollarAmountDueDouble * Tax_Rate_Decimal
SalesTaxTextBox.Text = SalesTaxDouble.ToString("C")
Else
SalesTaxDouble = 0.0
SalesTaxTextBox.Text = SalesTaxDouble.ToString("C")
End If
' Calculates Shipping and Handling Part A
PartWeightDecimal = QuantityInteger * WeightDecimal
PartWeightNewDecimal += PartWeightDecimal
Catch QuantityException As FormatException
' Handles a quantity exception
MessageBox.Show("The quantity must be a numeric. (Whole number)", "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
With QuantityTextBox
.Focus()
.SelectAll()
End With
End Try
Catch WeightException As FormatException
' Handles a weight exception.
MessageBox.Show("The weight must be a numeric.", "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
With WeightTextBox
.Focus()
.SelectAll()
End With
End Try
Catch PriceException As FormatException
' Handles a price exception.
MessageBox.Show("The price must be a numeric.(Dollars and cents)", "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
With PriceTextBox
.Focus()
.SelectAll()
End With
End Try
With DescriptionTextBox
.Focus()
.SelectAll()
End With
End Sub
When it runs the only catch that works is the only called PriceException. No idea why it isn't working. Can anyone help? Thanks in advance.