Option Compare Database
Option Explicit
Private mLstOne As Access.ListBox
Private mLstTwo As Access.ListBox
Private mX1 As Long
Private mY1 As Long
Private mX2 As Long
Private mY2 As Long
Private mItem1 As Integer
Private mItem2 As Integer
Private mLineCount As Integer
Const mMaxLines = 5
Private Sub Form_Load()
Set mLstOne = Me.lstOne
Set mLstTwo = Me.lstTwo
mLineCount = 1
End Sub
Public Property Get lstOneTop() As Long
lstOneTop = mLstOne.Top
End Property
Public Property Get lstTwoTop() As Long
lstTwoTop = mLstTwo.Top
End Property
Private Sub lstOne_Click()
mItem1 = lstOne.ListIndex
End Sub
Private Sub lstOne_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
mX1 = X + lstOne.Left
mY1 = Y + Me.lstOneTop
End Sub
Private Sub lstTwo_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
mX2 = X + Me.lstTwo.Left
mY2 = Y + Me.lstTwoTop
If mLineCount <= mMaxLines Then
ConnectLine Me.Controls("ln" & mLineCount)
Else
MsgBox "I only added 5 lines. You can add more"
End If
End Sub
Public Sub ConnectLine(ln As Access.Line)
'MsgBox Me.ln1.Top
Dim lnTop As Long
Dim lnWidth As Long
Dim lnHeight As Long
ln.Visible = True
ln.Left = lstOne.Left + lstOne.Width
ln.Width = Me.lstTwo.Left - Me.lstOne.Left - Me.lstOne.Width
If mY1 >= mY2 Then
ln.Top = mY2
ln.LineSlant = True
ln.Height = mY1 - mY2
Else
ln.LineSlant = False
ln.Top = mY1
ln.Height = mY2 - mY1
End If
mLineCount = mLineCount + 1
End Sub