Brad,
This sounds suspiciously like a school programming project and to get help from here would be cheating. However, since I cheated a lot in school and programmers "borrow" code all the time, here's the functions you're looking for.
Public Function x(a As Single, b As Single, c As Single) As Single
x = (a ^ 2 + c ^ 2 - b ^ 2) / 2 * c
End Function
Public Function y(a As Single, b As Single, c As Single) As Single
y = (a ^ 2 - x ^ 2) ^ (1 / 2)
End Function
Public Function Area(c As Single, y As Single) As Single
Area = (c * y) / 2
End Function
Mark,
I appreciate the help. I'm still confused if you could help me out. How do I make the values of a, b, and c be entered into a GUI by text boxes? I've written:
a = Val(txt1.Text)
b = Val(txt2.Text)
c = Val(txt3.Text)
and then I also need it to show the area in a list box. I need to draw it in a pic box too. I've tried:
picTriangle.Line (0, 0)-(c, 0)
picTriangle.Line (c, 0)-(x, y)
picTriangle.Line (x, y)-(0, 0)
I would really appreciate this if you could show your expertise on this.
thanks,
Brad
Brad,
No problem on the first part, second part I can't really help with.
Put those functions I gave you in a module are on the form or whatever you're using for the GUI.
To use the functions, you need this code.
' Declare Variables
dim a as single
dim b as single
dim c as single
dim MyX as single
dim MyY as single
dim MyArea as single
' Initialise Variables
a = Val(txt1.Text)
b = Val(txt2.Text)
c = Val(txt3.Text)
' To calculate x and y
MyX = x(a,b,c)
MyY = y(a,b,c)
' To calculate Area
MyArea = area(c, MyY)
' you should now use MyArea, MyX and MyY for drawing your triangle.
HTH
Mark,
Mark,
You're the man. I can get most of it to work but there's still some bugs. How do you write an error message? That is if I enter in wrong data in text box how can I pop up an error message saying the user screwed up? Also, what is the Cls method? I need to be able to clear the triangle (i did get it to draw!) and redraw everytime I enter new data for the sides.
Thanks,
Brad
No problem on the first part, second part I can't really help with. Put those functions I gave you in a module are on the form or whatever you're using for the GUI. To use the functions, you need this code.