Calculating Percentage

Hi,

Ive never had to deal with calculating percent in VB so I need some help.

Below is my code I through together but I of course it doesnt work.

So If someone could let me know if I am in the right direction.

thanks

Private Sub Sales1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Sales1.TextChanged
Call Commission()
End Sub
Private Sub Com1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Com1.TextChanged
Call Commission()
End Sub

Private Sub Commission()
Dim Sales, Com As Double

Sales = Double.Parse(Sales1.Text)
Com = Double.Parse(Com1.Text)

Com = Sales * Com / 100
Com = Sales + Com

Label18.Text = Sales.ToString

End SubIt is not clear what you are trying to output.

Obviously you are trying to to the field Label18.Text, but the value returned to it is just your Sales1.Text value, it's not a computed value.

If you are trying to just return the Commission for the Sales value than you just want

Private Sub Commission()

Dim Sales, Com As Double
Dim CalculatedValue As Double

Sales = Double.Parse(Sales1.Text)
Com = Double.Parse(Com1.Text)

CalculatedValue = Sales * Com / 100

Label18.Text = CalculatedValue .ToString

End Sub
 
Back
Top