[vb]代码库
Public Class Form1
Dim a, b As Integer
Dim full As Integer = 10000
Dim attack As Integer = 1000
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
Private Sub ButtonTime_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonTime.Click
Label1.Text = "现在时间" + Now
a = full
b = full
End Sub
Private Sub Button1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
'左键的话,标志位为true(表示拖拽开始)
If (e.Button = Windows.Forms.MouseButtons.Left) Then
Button1.DoDragDrop(Button1, DragDropEffects.Copy Or DragDropEffects.Move) '形成拖拽效果,移动+拷贝的组合效果
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.AllowDrop = True
End Sub
Private Sub Form1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragEnter
If (e.Data.GetDataPresent(GetType(Button))) Then '当Button被拖拽到WinForm上时候,鼠标效果出现
e.Effect = DragDropEffects.Move
End If
End Sub
Private Sub Form1_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragDrop
Button1.Location = Me.PointToClient(New Point(e.X, e.Y))
End Sub
End Class