locked
Operator '*' is not defined for types 'System.Web.UI.WebControls.TextBox' and 'System.Web.UI.WebControls.TextBox'. RRS feed

  • Question

  • User-626820762 posted

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="calctax.aspx.vb" Inherits="lab_week1_calctax" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">

    Public Sub Click(ByVal sender As Object, ByVal e As EventArgs)
    r.Text = r.ToString()
    i.Text = i.ToString()
    Label3.Text = r * i
    End Sub
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title></title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>

    <asp:Label ID="Label1" runat="server" Text="Tax Rate"></asp:Label>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:TextBox ID="r" runat="server" style="margin-left: 0px"></asp:TextBox>
    <br />
    <br />
    <asp:Label ID="Label2" runat="server" Text="Income"></asp:Label>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:TextBox ID="i" runat="server"></asp:TextBox>
    <br />
    <br />
    <asp:Button ID="Button1" runat="server" Text="Calculate" OnClick="Click"/>
    &nbsp;&nbsp;&nbsp;
    <asp:Label ID="Label3" runat="server" Text=""></asp:Label>

    </div>
    </form>
    </body>
    </html>

    What should i do to resolve this problem?
    what should i use to define mathematical operators? 

    Friday, August 10, 2012 9:12 AM

Answers

  • User1954304945 posted

    Hi, I have modified the codes, you can refer to them:

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="calctax.aspx.vb" Inherits="lab_week1_calctax" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
    
        Public Sub Click(ByVal sender As Object, ByVal e As EventArgs)
            Try
                Dim Rval As Integer = Int32.Parse(r.Text)
                Dim Ival As Integer = Int32.Parse(i.Text)
                Label3.Text = (Rval * Ival).ToString()
            Catch ex As Exception
                
            End Try
        End Sub
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Label ID="Label1" runat="server" Text="Tax Rate"></asp:Label>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:TextBox ID="r" runat="server" Style="margin-left: 0px"></asp:TextBox>
            <br />
            <br />
            <asp:Label ID="Label2" runat="server" Text="Income"></asp:Label>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:TextBox ID="i" runat="server"></asp:TextBox>
            <br />
            <br />
            <asp:Button ID="Button1" runat="server" Text="Calculate" OnClick="Click" />
            &nbsp;&nbsp;&nbsp;
            <asp:Label ID="Label3" runat="server" Text=""></asp:Label>
        </div>
        </form>
    </body>
    </html>
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 14, 2012 3:06 AM

All replies

  • User-1716253493 posted
    try dim ii as integer=i and try ii * rr maybe because i and r is string
    Friday, August 10, 2012 10:50 AM
  • User-1716253493 posted
    try this Label3.Text = r.text * i.text
    Friday, August 10, 2012 12:46 PM
  • User1954304945 posted

    Hi, I have modified the codes, you can refer to them:

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="calctax.aspx.vb" Inherits="lab_week1_calctax" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
    
        Public Sub Click(ByVal sender As Object, ByVal e As EventArgs)
            Try
                Dim Rval As Integer = Int32.Parse(r.Text)
                Dim Ival As Integer = Int32.Parse(i.Text)
                Label3.Text = (Rval * Ival).ToString()
            Catch ex As Exception
                
            End Try
        End Sub
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Label ID="Label1" runat="server" Text="Tax Rate"></asp:Label>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:TextBox ID="r" runat="server" Style="margin-left: 0px"></asp:TextBox>
            <br />
            <br />
            <asp:Label ID="Label2" runat="server" Text="Income"></asp:Label>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <asp:TextBox ID="i" runat="server"></asp:TextBox>
            <br />
            <br />
            <asp:Button ID="Button1" runat="server" Text="Calculate" OnClick="Click" />
            &nbsp;&nbsp;&nbsp;
            <asp:Label ID="Label3" runat="server" Text=""></asp:Label>
        </div>
        </form>
    </body>
    </html>
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 14, 2012 3:06 AM
  • User-2079544531 posted

    just do it this way

    Label3.Text = Int32.Parse(r.Text.toString()) * Int32.Parse(i.Text.toString())



    Tuesday, August 14, 2012 3:09 AM