Есть форма на ней поле 5 на5 и 20 лабелов , лабелы необходимо перетаскивать в любой из квадратов поля , возможны нахождение в одном поле нескольких лабелов ......
Подскажите как написать правильно код для такой задачи .....
(желательно с пояснением что бы сам знал что к чему)
мой код:
- Код: Выделить всё
Option Explicit
Dim lab As String
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
If lab = "label1" Then
Label1.Left = X
Label1.Top = Y
End If
If lab = "label2" Then
Label2.Left = X
Label2.Top = Y
End If
If lab = "label3" Then
Label3.Left = X
Label3.Top = Y
End If
If lab = "label4" Then
Label4.Left = X
Label4.Top = Y
End If
If lab = "label5" Then
Label5.Left = X
Label5.Top = Y
End If
If lab = "label6" Then
Label6.Left = X
Label6.Top = Y
End If
If lab = "label7" Then
Label7.Left = X
Label7.Top = Y
End If
If lab = "label8" Then
Label8.Left = X
Label8.Top = Y
End If
If lab = "label9" Then
Label9.Left = X
Label9.Top = Y
End If
If lab = "label10" Then
Label10.Left = X
Label10.Top = Y
End If
If lab = "label11" Then
Label11.Left = X
Label11.Top = Y
End If
If lab = "label12" Then
Label12.Left = X
Label12.Top = Y
End If
If lab = "label13" Then
Label13.Left = X
Label13.Top = Y
End If
If lab = "label14" Then
Label14.Left = X
Label14.Top = Y
End If
If lab = "label15" Then
Label15.Left = X
Label15.Top = Y
End If
If lab = "label16" Then
Label16.Left = X
Label16.Top = Y
End If
If lab = "label17" Then
Label17.Left = X
Label17.Top = Y
End If
If lab = "label18" Then
Label18.Left = X
Label18.Top = Y
End If
If lab = "label19" Then
Label19.Left = X
Label19.Top = Y
End If
If lab = "label20" Then
Label20.Left = X
Label20.Top = Y
End If
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label1"
End Sub
Private Sub Label2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label2"
End Sub
Private Sub Label3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label3"
End Sub
Private Sub Label4_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label4"
End Sub
Private Sub Label5_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label5"
End Sub
Private Sub Label6_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label6"
End Sub
Private Sub Label7_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label7"
End Sub
Private Sub Label8_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label8"
End Sub
Private Sub Label9_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label9"
End Sub
Private Sub Label10_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label10"
End Sub
Private Sub Label11_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label11"
End Sub
Private Sub Label12_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label12"
End Sub
Private Sub Label13_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label13"
End Sub
Private Sub Label14_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label14"
End Sub
Private Sub Label15_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label15"
End Sub
Private Sub Label16_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label16"
End Sub
Private Sub Label17_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label17"
End Sub
Private Sub Label18_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label18"
End Sub
Private Sub Label19_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label19"
End Sub
Private Sub Label20_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lab = "label20"
End Sub
заранее благодарен за помощь