比如说让用户移动在窗体上的一个标签,可以让用户任意摆放.

解决方案 »

  1.   

    Option Explicit
    Private labelx As Single
    Private labely As SinglePrivate Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
     If Button = vbLeftButton Then
        labelx = X
        labely = Y
     End If
     
    End SubPrivate Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
     If Button = vbLeftButton Then
        Label1.Left = Label1.Left + (X - labelx)
        Label1.Top = Label1.Top + (Y - labely)
     End If
    End Sub