Hello,

I am using the code below to add vb.Lines to my form.

My question is how do I delete the lines?

I tried me.Controls.Remove q_lines but that doesn't delete anymore then one line.

So if the user created 2 or even 10 lines how would I delete them?

Thank you and have a great!

Stilekid007

VB Code:
  1. Private q_InDrawMode As Boolean
  2. Private q_ActivateDrawmode As Boolean
  3. Private q_Lines As Line
  4.  
  5.  
  6. Private Sub Command1_Click()
  7. q_ActivateDrawmode = True
  8. End Sub
  9.  
  10.  
  11. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  12.      Static LineNumber As Long
  13.      LineNumber = LineNumber + 1
  14.    
  15.      If q_ActivateDrawmode = True Then
  16.         'create a new line and initialise it at the current mouse pointer
  17.      
  18.          Set q_Lines = Me.Controls.Add("VB.Line", "Line" & CStr(LineNumber), Form1)
  19.          q_Lines.X1 = X
  20.          q_Lines.X2 = X
  21.          q_Lines.Y1 = Y
  22.          q_Lines.Y2 = Y
  23.          q_Lines.Visible = True
  24.          q_InDrawMode = True
  25.     End If
  26.  
  27. End Sub
  28.  
  29. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  30.         If q_InDrawMode Then
  31.         'move the end point of the line
  32.         q_Lines.X2 = X
  33.         q_Lines.Y2 = Y
  34.     End If
  35.  
  36. End Sub
  37.  
  38. Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  39.     q_InDrawMode = False
  40.     q_ActivateDrawmode = False
  41. End Sub