|
-
Oct 15th, 2006, 12:08 PM
#1
Thread Starter
New Member
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
-
Oct 15th, 2006, 03:27 PM
#2
Re: question
Welome to the Forums
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
Last edited by zaza; Oct 15th, 2006 at 03:32 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|