turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Close

.NET

- Autodesk Community
- >
- AutoCAD Customization
- >
- .NET
- >
- Re: Help needed with Triangle solution calculator ...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page

Distinguished Mentor

582 Posts

91 Kudos

Registered:
04-11-2010

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-10-2012 11:42 AM in reply to:
SteveHeather7776

Hi,

I insist that you are confused your self because the wrong positioned a,b,c values over the triangle in your screen grab. If you have 3,4,5, then the value 5 MUST be over the hypotenuse, and NOT over a leg side. In other words where in the picture says "a" should be "c", and so with "c", given that yo are solving the Pythagoras in the standar form a*a+b*b=c*c. Other way just change the order of a,b,c in the formula.

Gaston Nunez

Active Member

8 Posts

0 Kudos

Registered:
03-19-2009

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-10-2012 12:53 PM in reply to:
gasty1001

There is nothing wrong with the pythagoras maths at all, it doesn't matter what you call the sides, they are just labels. It wouldn't matter if you called them side dog or side cat, it is the way in which you use them. If you look at the image I have attached you will see that it works ok for the pythagoras side of it.

Valued Mentor

341 Posts

53 Kudos

Registered:
05-12-2009

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-10-2012 01:12 PM in reply to:
SteveHeather7776

I would redo the code to make easier, but looking real quick think about this section of code.

If sideb = 0 Then sideb = Math.Sqrt((sidea * sidea) - (sidec * sidec)) TextBoxSideb.Text = sideb ElseIf sidea = 0 Then sidea = Math.Sqrt((sideb * sideb) + (sidec * sidec)) TextBoxSidea.Text = sidea ElseIf sidec = 0 Then sidec = Math.Sqrt((sidea * sidea) - (sideb * sideb)) TextBoxSidec.Text = sidec End If

You are assuming that 2 sides will always have a value.

The sides really do not equal 0 you are using it as placeholder, might be better to take a different approach

You can also find your answers @ TheSwamp

Active Member

8 Posts

0 Kudos

Registered:
03-19-2009

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-10-2012 07:24 PM in reply to:
jeff

Thanks for your reply, I think it is very obvious that I don't know very much about VB programming, but I never proffessed too either. So I am asking for help on the solution please, in other words, what is the best way to code this calculator. As I mentioned earlier, I learn things by trial and error, and by seeing correct examples that I can then manipulate into my programmes.

Many thanks,

Steve

Active Member

8 Posts

0 Kudos

Registered:
03-19-2009

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-10-2012 08:27 PM in reply to:
SteveHeather7776

Hi guys,

I have changed all the lettering around as per your instructions, and added some extra code, and it works properly.

Thanks for all your help.

Steve.

New code below, and image attached:

Imports System.String

Imports System.Math

Public Class Form1

Dim angleA As Single = 90

Dim angleB As Single

Dim angleC As Single

Dim sidea As Single

Dim sideb As Single

Dim sidec As Single

Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged

Controls.Add(NumericUpDown1)

End Sub

Public Function isItNullString(ByVal value) As Boolean

If value = "" Then

Return True

Else

Return False

End If

End Function

Public Sub pythagoreanTheoremThings()

If sidec <> 0 And sidea <> 0 And sideb = 0 Then

sideb = Math.Sqrt((sidec * sidec) - (sidea * sidea))

TextBoxSideb.Text = sideb

ElseIf sideb <> 0 And sidea <> 0 And sidec = 0 Then

sidec = Math.Sqrt((sideb * sideb) + (sidea * sidea))

TextBoxSidec.Text = sidec

ElseIf sidec <> 0 And sideb <> 0 And sidea = 0 Then

sidea = Math.Sqrt((sidec * sidec) - (sideb * sideb))

TextBoxSidea.Text = sidea

End If

End Sub

Public Sub angleSums()

If angleC = 0 And angleB <> 0 Then

angleC = 180 - angleA - angleB

TextBoxAngleC.Text = angleC

End If

If angleB = 0 And angleC <> 0 Then

angleB = 180 - angleA - angleC

TextBoxAngleB.Text = angleB

End If

End Sub

Public Sub angleBasWorkingAngle()

'Angle B and side b known, find side c

If angleB <> 0 And sideb <> 0 Then

sidec = sideb / Sin(degreesToRadians(angleB))

TextBoxSidec.Text = sidec

End If

'Angle B and side a known, find side b

If angleB <> 0 And sidea <> 0 Then

sideb = sidea * Tan(degreesToRadians(angleB))

TextBoxSideb.Text = sideb

End If

'Angle B and side b known, find side a

If angleB <> 0 And sideb <> 0 Then

sidea = sideb / Tan(degreesToRadians(angleB))

TextBoxSidea.Text = sidea

End If

'Angle B and side b known, find side a

If angleB <> 0 And sidec <> 0 Then

sidea = sidec * Cos(degreesToRadians(angleB))

TextBoxSidea.Text = sidea

End If

End Sub

Public Sub findangleC()

If angleC = 0 Then

'cos

angleC = radiansToDegrees(Acos(sideb / sidec))

TextBoxAngleC.Text = angleC

End If

End Sub

Public Sub feedValues()

If Not isItNullString(TextBoxSideb.Text) Then

sideb = TextBoxSideb.Text

Else

sideb = 0

End If

If Not isItNullString(TextBoxSidea.Text) Then

sidea = TextBoxSidea.Text

Else

sidea = 0

End If

If Not isItNullString(TextBoxSidec.Text) Then

sidec = TextBoxSidec.Text

Else

sidec = 0

End If

If Not isItNullString(TextBoxAngleC.Text) Then

angleC = TextBoxAngleC.Text

Else

angleC = 0

End If

If Not isItNullString(TextBoxAngleB.Text) Then

angleB = TextBoxAngleB.Text

Else

angleB = 0

End If

End Sub

Public Function degreesToRadians(ByVal degrees As Double) As Double

Dim radians As Double

radians = (Math.PI * degrees) / 180

Return radians

End Function

Public Function radiansToDegrees(ByVal radians As Double) As Double

Dim degrees As Double

degrees = radians * (180 / Math.PI)

Return degrees

End Function

#Region " Calculate all Data "

Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click

For aaa As Integer = 0 To 2 'I just repeated this 6 times because I have a lot of processing power

'you can do it twice.

feedValues()

pythagoreanTheoremThings()

angleSums()

angleBasWorkingAngle()

findangleC()

Next

End Sub

#End Region

#Region " Clear all input boxes "

Public Sub ClearTextBox(ByVal root As Control)

For Each ctrl As Control In root.Controls

ClearTextBox(ctrl)

If TypeOf ctrl Is TextBox Then

CType(ctrl, TextBox).Text = String.Empty

End If

Next ctrl

End Sub

#End Region

Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click

ClearTextBox(Me)

End Sub

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click

Me.Close()

End Sub

New Member

1 Posts

0 Kudos

Registered:
10-15-2012

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-15-2012 02:24 AM in reply to:
SteveHeather7776

..how to make triangle solver?where can i create like that one?i really need it because it is our project in trigonometry.thanks for the immediate respond=)

Search This Board

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Post to the Community

Have questions about Autodesk products? Ask the community.

The Knowledge Network

Access a broad range of knowledge to help get the most out of your products and services.

Download & Installation

Getting your Software

Downloads & Upgrades

Serial Numbers & Product Keys

Installation & Licensing

Activation & Registration

Network License Administration

Subscription Management

Sign In / Create Account

Maintenance Subscription Help

Desktop Subscription Help

Cloud Service Subscription FAQ

Announcements

Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!

- Privacy | Legal Notices & Trademarks | Report Noncompliance | Site map | © Copyright 2014 Autodesk Inc. All rights reserved

Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Please see the Autodesk Creative Commons FAQ for more information.