locked
code RRS feed

  • Question

  • User-90831357 posted

    This is the code I`m using and it was working before but now its giving me an error saying  Error 1 Operator '+' is not defined for types 'System.Windows.Forms.TextBox' and 'Double'. 

    for the sgTotal + 0.99

     

    Code: 

    If

    chkExtraCheese.Checked = True Then

    innumtoppings = innumtoppings + 1

    sgTotal = sgTotal + 0.99

     

    If innumtoppings > 5 Then

    MsgBox(

    chkExtraCheese.Checked =

    " You May Only Choose 5 Toppings ", vbOKOnly, " Too many toppings")False

     

    End If

     

    ElseIf chkExtraCheese.Checked = False Then

    innumtoppings = innumtoppings - 1

     

    End If

    txtTotalPrice.Text = Format(sgTotal,

     

    "currency")End Sub

    Sunday, January 2, 2011 6:49 PM

Answers

  • User-364289655 posted

    when referencing a textbox you need to call .Text

     

    If (chkExtraCheese.Checked) Then 
        innumtoppings = innumtoppings + 1
        sgTotal.Text = Double.Parse(sgTotal.Text) + 0.99
    


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, January 2, 2011 9:05 PM

All replies

  • User-364289655 posted

    when referencing a textbox you need to call .Text

     

    If (chkExtraCheese.Checked) Then 
        innumtoppings = innumtoppings + 1
        sgTotal.Text = Double.Parse(sgTotal.Text) + 0.99
    


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, January 2, 2011 9:05 PM
  • User-90831357 posted

    thank you  

    Sunday, January 2, 2011 9:20 PM
  • User-90831357 posted

    but do you know how what the code would be if for a radiobutton for Small. Like for my assignment I have to put this pizza order form and I'm suppose to but a radiobutton for Small, medium, large and XtraLarge but I don't know what the code would be?

    Sunday, January 2, 2011 9:24 PM
  • User-364289655 posted

    In asp.net , you would use <asp:radiobuttonlist runat="server" id="sizes"><asp:listItem>option1</asp:listitem></asp:radiobuttonlist>.


    http://www.w3schools.com/aspnet/control_radiobuttonlist.asp

    http://www.w3schools.com/aspnet/showasp.asp?filename=demo_radiobuttonlist

    Monday, January 3, 2011 2:49 PM