I am needing help in understanding how to declare variables properly. I am needing to write as program that calculates the commission for a sales person. I keep getting a error listed below. I thought I declared the salestextbox, costtextbox as integers correctly to use them in the calculation. I Copied my code below also. I have reread the chapter again and I am still lose. What am I doing wrong?

Error 1 Value of type 'Double' cannot be converted to 'System.Windows.Forms.TextBox'. C:\Users\Purrenhage\AppData\Local\Temporary Projects\WindowsApplication1\Autocenter3.vb 36 29 WindowsApplication1

' Scott Purrenhage
' 7-18-11
' Program is going to take a persons name, selling price, cost value and calculate the commission in a text box.
' The commission rate is set at 20%.
' Needs to have a print, clear input, and exit buttons.
' needing to be able to give a error message to the user to correct input values.

Public Class AutoCenter3Form
    'Declaring variables

    Const COMMISSION_RATE As Decimal = 0.2D

    Private Sub PrintButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintButton.Click
        'print to a preview
        PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
        PrintForm1.Print()
    End Sub

    Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
        'Exit the program
        Me.Close()
    End Sub

    Private Sub ClearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButton.Click
        ' Clear all the input values
        NameBox.Text = String.Empty
        SalestextBox.Text = String.Empty
        Costtextbox.Text = String.Empty
    End Sub

    Private Sub CalcButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalcButton.Click
        'Calculate the commission and display it in the commissiontextbox
        Dim Salestextbox, Costtextbox As Integer
        Salestextbox = Integer.Parse(Salestextbox.ToString)
        Costtextbox = Integer.Parse(Costtextbox.ToString)
        Commissiontextbox = COMMISSION_RATE * (Salestextbox - Costtextbox).ToString("C")

    End Sub
End Class

You are declaring the Salestextbox, Bosttextbox as integers, while at the same time you are using these names for textboxes?
Why not go ahead and use

Salestextbox.text= integer.parse(Salestextbox.text.tostring)

(Notice that both times I'm using textbox.text and not the actual textbox, which is an object and not the object's text).

You are declaring the Salestextbox, Bosttextbox as integers, while at the same time you are using these names for textboxes?
Why not go ahead and use

Salestextbox.text= integer.parse(Salestextbox.text.tostring)

(Notice that both times I'm using textbox.text and not the actual textbox, which is an object and not the object's text).

So to understand what you are saying better Salestextbox is one kind of object and salestextbox.text is a different one?

No, Salestextbox is an object.
.text is a property of the salestextbox (or of any textbox).
.width is another property of the salestextbox (or of any textbox).

You can't do calculations using the whole text box, which is an object and not the text you see in that object. (Like you wouldn't be able to do calculations with the whole form).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.