that the "Sales amount must be numeric" I do not know what is wrong with the code I think I am not doing the conversion right
here is the code
thanks in advance
Option Explicit On
Option Strict On
Imports System.Globalization
Public Class MainForm
Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
'Close the form
Me.Close()
End Sub
Private Sub calcButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles calcButton.Click
' calculates a bonus amount
Dim code As String
Dim sales As Decimal
Dim bonus As Decimal
Dim isConverted As Boolean
' convert sales amount to a number
isConverted = Decimal.TryParse(salesTextBox.Text, NumberStyles.Currency, _
NumberFormatInfo.CurrentInfo, sales)
If isConverted Then
code = codeTextBox.Text
If code = "1" OrElse code = "2" AndAlso sales > 10000 Then
bonus = sales * 0.1D
Else
bonus = sales * 0.05D
End If
MessageBox.Show("Your bonus is " & bonus.ToString("C2"), _
"Bonus Calculator", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("The sales amount must be numeric.", _
"Bonus Calculator", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
' set the focus
codeTextBox.Focus()
End Sub
End Class

New Topic/Question
Reply




MultiQuote






|