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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help for code for area of triangle

Status
Not open for further replies.

Zardos

Technical User
Apr 23, 2002
2
US
area of triange code the base + height are entered by textboxes but the answer must display in a label which i called area
 
cmdDisplayArea_Click()
Dim lngB As Long
Dim lngH As Long
Dim lngA As Long

lngB = CLng(txtBase.text)
lngH = CLng(txtHeight.text)
lngA = (lngB * lngH)/2

lblArea.Caption = CStr(lngA)

End Sub
Anything is possible, the problem is I only have one lifetime.
 
the answer that has been given is only for a right angle triangle though
 
Sorry, but I assumed that the coding was the topic not the geometry. Anything is possible, the problem is I only have one lifetime.
 
If you need to run the .exe and wait for it to finish, check out faq222-428.
 
Actually, ghobbes98, foada's code AND geometry is correct; you simply have to remember that the height is always the height PERPENDICULAR to the base. This, of course, works for all triangles. "It's got to be the going,
not the getting there that's good!"
-Harry Chapin
 
Thanks missinglinq,

I could have sworn that was correct but it has been a while since I did that sort of calculation so I was starting to doubt myself. [thumbsup2]

Anything is possible, the problem is I only have one lifetime.
 
Foada, couldn't be much any longer for you than me (took geometry last in 1964). I thought you were right, but I did look it up before tapping. It's amazing; I remember not only the songs we played at the homecoming dance in 1968, but the arrangements as well, but I have a real hard time remembering what I had for lunch last week!

Linq "It's got to be the going,
not the getting there that's good!"
-Harry Chapin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top