Calculate Area of Triangle with VB6

By | 2019-01-02

This is a quick example of how to implement a basic math formula within your program.

The example project only contains one form, with three fields and a button:

Triangle Area Calculator Example

All three fields need to be populated with values, which is checked for in the code. Also, this example will only let you enter numeric values in the fields, in order to prevent errors which would be generated by entering other (or invalid) characters.

Given the length of all three sides of a triangle, along with the use of Herons formula, the program will calculate the total area of the triangle. 

Just a little something to get some folks started in the right direction on their homework assignments. 😉

Webmaster Note

This article has been updated to reflect the correct outcome. The previous version of the article made use of an incomplete process to find the area of a triangle, and skipped the use of Herons formula.

Herons formula states:

AREA = sqrt(s(s-a)(s-b)(s-c))

Where:

s = SemiPerimeter of the triangle, and a, b, and c are the lengths of the individual sides.

Thanks to an angry math nerd in middle America, who has a penchant for irate rants, for pointing out the mistake. The code has been updated, and the author responsible for the error has been beaten to within an inch of his life.

To the angry old man, I hope this sates your quest for accuracy. Now that the author and myself have fixed the error, you have all the time in the world to fix dotnetplayground. That is, unless you are dedicating your life to harassing random websites.

Attachments

FileUploadedSize
389-20190416-150447-TriangleArea.zip4/16/2019 3:04:47 PM1932
Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.