在form中动态生成10个等间距、垂直的line1(i)控件
想实现的功能是:可以用鼠标调整任意一个line的水平位置
我的代码如下:
'生成动态数组控件
Private Sub Form_Load()
For i = 1 To 10
  Load Line1(i)
  Line1(i).Visible = True
  Line1(i).X1 = i * Form1.Width / 11
  Line1(i).X2 = Line1(i).X1
  Line1(i).Y1 = 1
  Line1(i).Y2 = Form1.Height
Next
End Sub然后就不知道该怎么写了
请各位高手赐教!谢谢!

解决方案 »

  1.   

    还是自己解决了
    Dim temp_i As Integer
    Dim modify_click As Boolean
    Dim modify_up As Integer
    Private Sub Form_Load()
    For i = 1 To 10
      Load Line1(i)
      Line1(i).Visible = True
      Line1(i).X1 = i * Form1.ScaleWidth / 11
      Line1(i).X2 = Line1(i).X1
      Line1(i).Y1 = 1
      Line1(i).Y2 = Form1.ScaleHeight
    Next
    End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
      For i = 1 To 10
        If Line1(i).X1 = X Then
          modify_click = True
          temp_i = i            '保存修改线段的序号
        '  MsgBox (i & "  |  " & X)
          Exit Sub
        End If
      Next
    End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If modify_click = True Then
      Line1(temp_i).X1 = X
      Line1(temp_i).X2 = X
      'Form1.Refresh
      'MsgBox (X)
    End If
    End SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    modify_up = True
    modify_click = False
      Line1(temp_i).X1 = X
      Line1(temp_i).X2 = X
    modify_up = False
    End Sub
      

  2.   


    自己的问题还是自己做了
    虽然费时较久
    但记忆深刻
    还能增强信心
    有空多交流
    [email protected]