I am very new to visual basic and I am having problems with my code. I think it is my case statement. Everything else is working fine. But when I try to calculate the commission it returns a $0.00
Thanks for any help you can offer. I am really stuck.
Code:
Public Class Form1
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
'closes the application
End
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
'clear all textboxes and labels
txtSalesPersonLevel.Text = ""
txtWeeklySales.Text = ""
lblCommission.Text = ""
txtSalesPersonLevel.Focus()
End Sub
Private Sub lblCommission_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCommission.Click
'declare variables for each category
Dim dblSalesPersonLevel As Double
Dim dblWeeklySales As Double
Dim dblCommission As Double
Dim dblPercent As Decimal
lblCommission.Text = Format(dblCommission, "C")
'check to see if sales level entered is less than 1 or greater than 4
If Val(txtSalesPersonLevel.Text) < 1 Or Val(txtSalesPersonLevel.Text) > 4 Then
MessageBox.Show("Sales level can only be between 1 and 4")
txtSalesPersonLevel.Select()
'breaks out of procedure
Else
'get the sales person level
dblSalesPersonLevel = Val(txtSalesPersonLevel.Text)
End If
'check to see if sales amount entered is between 1 and 100,000
If Val(txtSalesPersonLevel.Text) < 1 Or Val(txtSalesPersonLevel.Text) > 100000 Then
MessageBox.Show("Sales can only be between $1 and $100,000")
Else
'get the sales level
dblWeeklySales = Val(txtWeeklySales.Text)
End If
Exit Sub 'breaks out of procedure
Select Case dblWeeklySales
Case Is >= 500
dblPercent = 0.02
Case Is < 1000
dblPercent = 0.03
Case Is < 1250
dblPercent = 0.04
Case Else
dblPercent = 0.05
dblCommission = dblWeeklySales * dblPercent
End Select
End
End Sub