Ok I'm writing a triangle app and I need to pass coordinates from one function to another. Here is a sample of the code so far:
Private Sub cmdArea_Click()
Dim Area As Double
Call Area(X1, X2, X3, Y1, Y2, Y3, Area)
lblArea = Area
End Sub
------------------------------------------------
Private Sub cmdSides_Click()
'User entered inputs
Dim X1, X2, X3, Y1, Y2, Y3 As Double
'Length of each sides
Dim A, B, C As Double
X1 = Val(txtX1.Text)
X2 = Val(txtX2.Text)
X3 = Val(txtX3.Text)
Y1 = Val(txtY1.Text)
Y2 = Val(txtY2.Text)
Y3 = Val(txtY3.Text)
Call Sides(X1, Y1, X2, Y2, A)
lblA = A
Call Sides(X2, Y2, X3, Y3, B)
lblB = B
Call Sides(X3, Y3, X1, Y1, C)
lblC = C
End Sub
-------------------------------------------
Private Sub Sides(X1, Y1, X2, Y2, S)
S = Sqr((X1 - X2) ^ 2 + (Y1 - Y2) ^ 2)
End Sub
-----------------------------
Private Sub Area(X1, X2, X3, Y1, Y2, Y3, Area)
'Semi Perimeter
Dim SP As Double
Call cmdSides_Click(A, B, C)
SP = (A + B + C) / 2
Area = Sqr(SP(SP - A) * (SP - B) * (SP - C))
End Sub
--------------------
As you can probably see, the Area command is trying to pass coordinates that don't reside in it! For some reason I can't get the concept of passing variables to work in my head and it bothers me a lot. So the question is, when the user hits the Area button, how can I get it to send coordinates to the Area function? I need to keep from making things global. Thanks
Private Sub cmdArea_Click()
Dim Area As Double
Call Area(X1, X2, X3, Y1, Y2, Y3, Area)
lblArea = Area
End Sub
------------------------------------------------
Private Sub cmdSides_Click()
'User entered inputs
Dim X1, X2, X3, Y1, Y2, Y3 As Double
'Length of each sides
Dim A, B, C As Double
X1 = Val(txtX1.Text)
X2 = Val(txtX2.Text)
X3 = Val(txtX3.Text)
Y1 = Val(txtY1.Text)
Y2 = Val(txtY2.Text)
Y3 = Val(txtY3.Text)
Call Sides(X1, Y1, X2, Y2, A)
lblA = A
Call Sides(X2, Y2, X3, Y3, B)
lblB = B
Call Sides(X3, Y3, X1, Y1, C)
lblC = C
End Sub
-------------------------------------------
Private Sub Sides(X1, Y1, X2, Y2, S)
S = Sqr((X1 - X2) ^ 2 + (Y1 - Y2) ^ 2)
End Sub
-----------------------------
Private Sub Area(X1, X2, X3, Y1, Y2, Y3, Area)
'Semi Perimeter
Dim SP As Double
Call cmdSides_Click(A, B, C)
SP = (A + B + C) / 2
Area = Sqr(SP(SP - A) * (SP - B) * (SP - C))
End Sub
--------------------
As you can probably see, the Area command is trying to pass coordinates that don't reside in it! For some reason I can't get the concept of passing variables to work in my head and it bothers me a lot. So the question is, when the user hits the Area button, how can I get it to send coordinates to the Area function? I need to keep from making things global. Thanks