Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

show a result to a label 1

Status
Not open for further replies.

tougo

Technical User
Sep 9, 2002
27
GB
i come from a c++builder enviroment and i was convinced to try C# so i tried to rewrite a simple old program from c++ to c#. that's what i've done so far..it compiles perfectly but does not work at all!!

private void button1_Click(object sender, System.EventArgs e)
{
double xz = Convert.ToDouble(textBox1.Text);
double yz = Convert.ToDouble(textBox2.Text);
double yx = Convert.ToDouble(textBox3.Text);
double xx = Convert.ToDouble(textBox4.Text);
double yy = Convert.ToDouble(textBox5.Text);
double xy = Convert.ToDouble(textBox6.Text);
double dxxz,dxyz,dyxz,dyyz, b1, b2,x0, y0, c, lx,ly, lz;
dxxz = xx - xz;
dxyz = xy - xz;
dyxz = yx - yz;
dyyz = yy - yz;
b1 = yx * dyyz + xx * dxyz;
b2 = yy * dyxz + xy * dxxz;
x0 = (b1 * dyxz - b2 * dyyz)/(dyxz * dxyz + dyyz * dxxz);
y0 = (b1 * dxxz - b2 * dxyz)/(dyxz * dxyz + dyyz * dxxz);
c = Math.Sqrt(-(xx -x0) * (xy -x0) - (yx -y0) * (yy - y0));
lx = Math.Sqrt(Math.Pow(xx-x0,2)+ (yx - y0) + Math.Pow(c,2));
ly = Math.Sqrt(Math.Pow(xy-x0,2)+ (yy - y0) + Math.Pow(c,2));
lz = Math.Sqrt(Math.Pow(xz-x0,2)+ (yz - y0) + Math.Pow(c,2));
x0= Convert.ToDouble(label27.Text);
y0= Convert.ToDouble(label28.Text);
 
Try reversing the assignment at the end. Instead of:
x0= Convert.ToDouble(label27.Text);
y0= Convert.ToDouble(label28.Text);

Try:
label27.Text = x0.ToString();
label28.Text = y0.ToString();

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top