-
question
im doing a project for school and i cant figure this out...
Private Sub btnCalculate_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim txtTotalSales As Single
Dim txtCommissionPer As Single
txtTotalSales = CSng(txtTotalSales)
txtCommissionPer = CSng(txtCommissionPer)
'Calculate Commission
txtTotal = txtTotalSales * txtCommissionPer
'Display Commission
txtTotal.Text = FormatCurrency(txtTotal)
End Sub
that txtTotalSales * txtCommissionPer is coming up with an error that says value of 'single' cannot be converted to 'system.windows.form.textbox'
any help would be Greatly apreciated
-
Re: question
Welome to the Forums :wave:
You've used txtTotal on its own in that line, as though it was a variable, but which I guess (from a later line) refers to another textbox. If you want to refer to a property of an object, then refer to it. So don't name variables to be the same as objects and don't take the lazy option and let VB work out what property you want to use. Best to get into good habits sooner rather than later, otherwise unpredictable errors might result (as you have discovered).
zaza