C
Cosmic Jay
Guest
Here is my code. Please help me.
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
' The btnCalculate event handler calculates the estimate cost of
' cabinets based on the linear feet and the wood type.
' Delcaration Section
Dim decFeet As Decimal
Dim decCostPerFoot As Decimal
Dim decCostEstimate As Decimal
Dim decPineCost As Decimal = 160
Dim decOakCost As Decimal = 230
Dim decCherryCost As Decimal = 400
Dim decHickoryCost As Decimal = 280
' Did user enter a numeric value?
If IsNumeric(txtFeet.Text) Then
decFeet = Convert.ToDecimal(txtFeet.Text)
' Is linear feet greater than zero
If decFeet > 0 Then
' Determine cost per foot of wood
If radPine.Checked Then
decCostPerFoot = decPineCost
ElseIf radOak.Checked Then
decCostPerFoot = decOakCost
ElseIf radCherry.Checked Then
decCostPerFoot = decCherryCost
ElseIf radHickory.Checked Then
decCostPerFoot = decHickoryCost
End If
'Calculate and display cost estimate
decCostEstimate = decFeet * decCostPerFoot
lblCostEstimate = decCostEstimate.ToString("C")
Else
' Display error message if user entered a negative value
MsgBox("You entered " & decFeet.ToString() & ". Enter a postive number", , "Input Error")
txtFeet.Text = ""
txtFeet.Focus()
End If
Else
' Display error message if user entered a numeric value
MsgBox("Enter the linear feet of the cabinets", , "Input Error")
txtFeet.Text = ""
txtFeet.Focus()
End If
End Sub
End Class
Continue reading...
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
' The btnCalculate event handler calculates the estimate cost of
' cabinets based on the linear feet and the wood type.
' Delcaration Section
Dim decFeet As Decimal
Dim decCostPerFoot As Decimal
Dim decCostEstimate As Decimal
Dim decPineCost As Decimal = 160
Dim decOakCost As Decimal = 230
Dim decCherryCost As Decimal = 400
Dim decHickoryCost As Decimal = 280
' Did user enter a numeric value?
If IsNumeric(txtFeet.Text) Then
decFeet = Convert.ToDecimal(txtFeet.Text)
' Is linear feet greater than zero
If decFeet > 0 Then
' Determine cost per foot of wood
If radPine.Checked Then
decCostPerFoot = decPineCost
ElseIf radOak.Checked Then
decCostPerFoot = decOakCost
ElseIf radCherry.Checked Then
decCostPerFoot = decCherryCost
ElseIf radHickory.Checked Then
decCostPerFoot = decHickoryCost
End If
'Calculate and display cost estimate
decCostEstimate = decFeet * decCostPerFoot
lblCostEstimate = decCostEstimate.ToString("C")
Else
' Display error message if user entered a negative value
MsgBox("You entered " & decFeet.ToString() & ". Enter a postive number", , "Input Error")
txtFeet.Text = ""
txtFeet.Focus()
End If
Else
' Display error message if user entered a numeric value
MsgBox("Enter the linear feet of the cabinets", , "Input Error")
txtFeet.Text = ""
txtFeet.Focus()
End If
End Sub
End Class
Continue reading...