How to get values from textboxes

Hey guys, I’m creating a project with web services. So txtA get tha quantity and txtB get the price. With these to values I want to passess as parameters to one method to realize a simple multiply to get the result in a label.

Do you mean that you are accessing a mySQL database with PHP and want to output in HTML the result of multiplying the quantity and the unit price, values from columns of one row of a database table?

How far have you got with it?

I’m using C# with webservices. So, i got the quantity and the price in two diferente texboxes. I want to create a method to do a simple aritmetic operation then show the result in one label. My question is how i can get the value from the textboxes to do that?

Ah - C# - I’m afraid then that I cannot help.

I’m actually resolve that problem but another thing appear now.

   private void txtPrecioxUnidad_TextChanged(object sender, EventArgs e)
        {
            /*This line don't get the correct format but when I
            Save it with my method the data get in the BD*/
            int cantidad = int.Parse(txtCantidad.Text);
            double precio = double.Parse(txtPrecioxUnidad.Text);

            double res = precio * cantidad;

            lblTotal.Text = res.ToString();


        }

I’m surprised you’re not getting an error on that calculation. Multiplying ints and doubles typically causes an error.

Cast the int as a double in the math…

double res = precio * (double)cantidad;
1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.