Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi friends,

in the code below how can I save the value of expression (I commented there) into a textbox?
Thanks.

C#
public double bigzarb(double u,double v)
     {
         double n;
         double x=0;
         double y;
         double w=0;
         double z;
         string[] i = textBox7.Text.Split(',');
         int[] nums = new int[i.Length];
         for (int counter = 0; counter < i.Length; counter++)
         {
             nums[counter] = Convert.ToInt32(i[counter]);
         }
         u = nums[0];
         double firstdigits =Math.Floor(Math.Log10(u) + 1);
          v = nums[1];
         double seconddigits = Math.Floor(Math.Log10(v) + 1);
         if (firstdigits >= seconddigits)
         {
             n = firstdigits;
         }
         else
         {
             n = seconddigits;
         }
         if (u == 0 || v == 0)
         {
             MessageBox.Show("the Multiply is 0");
         }
         int intn = Convert.ToInt32(n);
         if (intn <=3)
         {
             double uv = u * v;
             string struv = uv.ToString();
             MessageBox.Show(struv);
             return uv;
         }
         else
         {
            int m  =Convert.ToInt32(Math.Floor(n / 2));
             x = u % Math.Pow(10,m);
             y = u / Math.Pow(10, m);
             w = v % Math.Pow(10,m);
             z = v / Math.Pow(10,m);
             return  bigzarb(x, w) *Math.Pow(10,m)+ (bigzarb(x,w)+bigzarb(w,y))*Math.Pow(10,m) +bigzarb(y,z);
///how can i show the value  of the line above in a textbox?
         }
     }
Posted
Updated 19-Dec-10 23:41pm
v2
Comments
johannesnestler 20-Dec-10 5:56am    
What do you mean with "value of expression"?

You want to write the result?

Just convert it to string and and show it in your textbox:

textBox1.Text = bigzarb(1d, 2d).ToString();
johannesnestler 20-Dec-10 5:58am    
and don't tell me about unreachable code detected - this problem is inside your function - click on the warning and correct your code. If you don't understand the error you need to learn C#
Vigneshb6 20-Dec-10 8:05am    
good answer

Is that what you want?

double result = bigzarb(x, w) *Math.Pow(10,m)+ (bigzarb(x,w)+bigzarb(w,y))*Math.Pow(10,m) +bigzarb(y,z);
textBox1.Text = result.ToString()
return result;
 
Share this answer
 
Comments
arashmobileboy 20-Dec-10 5:52am    
it gives warning unreachable code detected
JF2015 20-Dec-10 5:53am    
if you replace the last line of your code ("return bigzarb(x, w).....") with my code you should not get this error.
arashmobileboy 20-Dec-10 6:40am    
ok,ir corrected,thanks
Try this,
textBox1.Text = bigzarb(1.0,2.0)

Pass the u and v value.
 
Share this answer
 
v2
Comments
arashmobileboy 20-Dec-10 5:50am    
it gives error cannot convert double to string,and i did textbox1.text=bigzarb(1.0,2.0).tostring(); but it gives unreachable code detected warning
Toniyo Jackson 20-Dec-10 5:53am    
Keep break point and check where you are getting error?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900