首先,设置OLEDropMode
OLEDropMode = 1
然后插入代码
Private Sub 控件名_OLEStartDrag(Data As DataObject, AllowedEffects As Long) AllowedEffects = vbDropEffectMoveEnd Sub
然后插入事件处理的代码
Private Sub 控件名_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single) Dim i As Long If Data.GetFormat(vbCFText) Then 得到拖放的字符串 = Data.GetData(vbCFText) ElseIf Data.GetFormat(vbCFFiles) Then If Data.Files.Count > 0 Then For i = 1 To Data.Files.Count 得到拖放的文件名 = Data.Files.Item(i) '其它的业务代码 Next i End If End IfEnd Sub
拖放的信息都获取到了,接下来就做你爱做的事情吧。