As you can see I can use the fallowing code that relies on "If" statments to determin the intersection point ...
Public Function VLineIntersect(ByVal X1 As Single, ByVal Y1 As Single, ByVal X2 As Single, ByVal Y2 As Single, _
ByVal LineX As Single, ByVal Top As Single, ByVal Bottom As Single, ByRef Value As Single) As Boolean
If (X1 < LineX And X2 < LineX) Or (X1 > LineX And X2 > LineX) Then Return False
Dim TY, BY As Single
If Top > Bottom Then
TY = Bottom
BY = Top
Else
TY = Top
BY = Bottom
End If
If X1 = X2 And X1 = LineX Then
If Y1 >= TY And Y1 <= BY Then
Value = Y1
Return True
End If
If Y1 > Y2 Then
If Y1 >= BY And Y2 <= BY Then
Value = BY
Return True
End If
If Y1 > BY Then Return False
Else
If Y1 <= TY And Y2 >= TY Then
Value = TY
Return True
End If
If Y2 < TY Then Return False
End If
End If
Dim YPos As Single
YPos = Y1 + ((LineX - X1) * (Y2 - Y1) / (X2 - X1))
If YPos >= TY And YPos <= BY Then
Value = YPos
Return True
End If
Return False
End Function
... Although the code works I would like to replace the 'If ... else' logic with a mathmatical formula if possible.