Help me fix this problem

visual studio 2005 , asp.net , vb.net Cardiff, United Kingdom
  • 10 years ago

    The code below is for a mini calculator that add two numbers entered in the two text boxes. I am using visual web developer 2005 express to develop. But it's always showing errors that "Operand1TextBox.Text and Operand2TextBox.Text are not declared"

    Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
    
    End Sub
    
    Protected Sub AddButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim op1, op2, result As Single
        op1 = Convert.ToSingle(Operand1TextBox.Text)
        op2 = Convert.ToSingle(Operand2TextBox.Text)
        result = op1 + op2
        resultLabel.Text = result.ToString()
    End Sub
    
  • 10 years ago

    Why Operand1 and Operand2?

    op1 = Convert.ToSingle(TextBox1.Text)
    op2 = Convert.ToSingle(TextBox2.Text)
    

    This is just fine. You have to pass values by the names of the controls you have used.

    www.consultsarath.info

  • 9 years ago

    Website changed

    www.consultsarath.com

    Contact for technical queries.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“If debugging is the process of removing software bugs, then programming must be the process of putting them in.” - Edsger Dijkstra