Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 136,545 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,846 people online right now. Registration is fast and FREE... Join Now!




Pythagoris's picture

 
Reply to this topicStart new topic

Pythagoris's picture, Display a triangle with sides marked.

Smurphy
21 Aug, 2008 - 05:58 AM
Post #1

New D.I.C Head
*

Joined: 7 Jul, 2008
Posts: 47



Thanked: 1 times
My Contributions
What I want to do is develop a windows form application. What I want it to do is take the input for the pathagorian theorm A^2+B^2=C^2
and display it to the sides of a picture of a triangle. But I do not know how to get the outputs to display around the picture. So if anybody could help that would be appreciative. (as a note this is not class work this is just for fun) School does not start until next week for me. biggrin.gif Thanks again.
User is offlineProfile CardPM
+Quote Post

modi123_1
RE: Pythagoris's Picture
21 Aug, 2008 - 07:17 AM
Post #2

D.I.C Addict
Group Icon

Joined: 12 Jun, 2008
Posts: 531



Thanked: 13 times
Dream Kudos: 100
My Contributions
Are you drawing the triangle on the fly or having a static image.. I'll let you figure out which one is a more simple job... lol.
User is offlineProfile CardPM
+Quote Post

SpiderSpartan
RE: Pythagoris's Picture
21 Aug, 2008 - 08:05 AM
Post #3

D.I.C Head
Group Icon

Joined: 6 Feb, 2008
Posts: 66



Thanked: 3 times
Dream Kudos: 25
My Contributions
QUOTE(modi123_1 @ 21 Aug, 2008 - 08:17 AM) *

Are you drawing the triangle on the fly or having a static image.. I'll let you figure out which one is a more simple job... lol.


I'd say definitely go with the static picture of a triangle, and then just use text boxes.
User is offlineProfile CardPM
+Quote Post

Smurphy
RE: Pythagoris's Picture
21 Aug, 2008 - 09:10 AM
Post #4

New D.I.C Head
*

Joined: 7 Jul, 2008
Posts: 47



Thanked: 1 times
My Contributions
Static for the love of god save me from drawing it on the fly lol. I do not want to make this any more difficult than it has to be.
User is offlineProfile CardPM
+Quote Post

Smurphy
RE: Pythagoris's Picture
21 Aug, 2008 - 06:31 PM
Post #5

New D.I.C Head
*

Joined: 7 Jul, 2008
Posts: 47



Thanked: 1 times
My Contributions
Ok now I am having more problems. How do I take the numbers form the text boxes convert them to integers then display them in labels.
User is offlineProfile CardPM
+Quote Post

modi123_1
RE: Pythagoris's Picture
22 Aug, 2008 - 08:42 AM
Post #6

D.I.C Addict
Group Icon

Joined: 12 Jun, 2008
Posts: 531



Thanked: 13 times
Dream Kudos: 100
My Contributions
Why would you need to convert them to integers if you are going from a textbox (string) to a lable (string)?

label.text = textbox.text
User is offlineProfile CardPM
+Quote Post

Smurphy
RE: Pythagoris's Picture
22 Aug, 2008 - 05:37 PM
Post #7

New D.I.C Head
*

Joined: 7 Jul, 2008
Posts: 47



Thanked: 1 times
My Contributions
I finally did it finished the application this application uses three text boxes, one button, and three labels.
Tell me what you think of the code I do realize she is not very pretty so any ways to make what I did easier would be appreciated. But try not to ruin it to much it works and I was very excited for my first app. wub.gif

CODE
//check to see if value null
            while(sin.Text == "")
            {//if it is tell the person
                MessageBox.Show("always put in a value if value unknown input 0 I just did it for you this time though:)");
                //input for them
                sin.Text = ("0");

                
            }
             while(cos.Text == "")
                {
                    MessageBox.Show("always put in a value if value unknown input 0 I just did it for you this time though:)");
                    cos.Text = ("0");
                    
                }
                 while(hypot.Text == "")
                    {
                        MessageBox.Show("always put in a value if value unknown input 0 I just did it for you this time though:)");
                        hypot.Text = ("0");
                    }

            {

                if (sin.Text != "")
                {
                    sinresult.Text = ("");
                }
                else
                    if (cos.Text != "")
                    {
                        cosresult.Text = ("");
                    }
                    else
                        if (hypot.Text != "")
                        {
                            hypotresult.Text = ("");
                        }





                if (Convert.ToDouble(sin.Text) == 0)
                {//convert text to number
                    //call ints
                    double store;
                    double store2;
                    double store3;
                    store2 = Convert.ToDouble(hypot.Text);
                    store3 = Convert.ToDouble(cos.Text);
                    store = System.Math.Pow(store2, 2) - System.Math.Pow(store3, 2);//do math
                    store = System.Math.Sqrt(store);
                    //send results to label
                    sinresult.Text = Convert.ToString(store);


                }
                else

                    if (Convert.ToDouble(cos.Text) == 0)
                    {
                        double store4;
                        double store5;
                        double store6;
                        store4 = Convert.ToDouble(hypot.Text);
                        store5 = Convert.ToDouble(sin.Text);
                        store6 = System.Math.Pow(store4, 2) - System.Math.Pow(store5, 2);
                        store6 = System.Math.Sqrt(store6);
                        cosresult.Text = Convert.ToString(store6);


                    }

                    else
                        if (Convert.ToDouble(hypot.Text) == 0)
                        {
                            double store7;
                            double store8;
                            double store9;
                            store7 = Convert.ToDouble(sin.Text);
                            store8 = Convert.ToDouble(cos.Text);
                            store9 = Convert.ToDouble(System.Math.Pow(store7, 2) + System.Math.Pow(store8, 2));
                            store9 = System.Math.Sqrt(store9);
                            hypotresult.Text = Convert.ToString(store9);



User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 10:55PM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month