OleDragDrop




Private Sub text1_OLEDragDrop(Data As DataObject, _
Effect As Long, Button As Integer, _
Shift As Integer, X As Single, Y As Single)

'Prepare a variable (numfiles) and pass the number of files

'dropped onto text1 to this variable


Dim numFiles As Integer

numFiles = Data.Files.Count
'an example how to trap 1 file (can be modified to trap as many

'or as little amount by changing the > 1 to > {new value}) then

'display a message box telling user the maximum allowed file drops)

'then exit the sub


If numFiles > 1 Then
MsgBox "Only allows 1 file at a time In beta version! Sorry!"_
,vbOKOnly, "Ooops beta version"
Exit Sub
End If

If (GetAttr(Data.Files(1))) = vbDirectory Then
MsgBox _
"beta version only allows files Not directories to be installed"
Exit Sub
End If

' check the file is the correct file type (using its extension)

' if not then warn user and exit the sub

'

If LCase(Right(Data.Files(1), 3)) <> LCase("bsp") Then
MsgBox "This file is Not a quake 2 map (*.bsp)"
Exit Sub
End If

'tell user the drag and drop was succesful


MsgBox Data.Files(1) + " installed"

End Sub tra Explorer ed una textbox
Inputs:a
dropped file from windows explorer

Assumes:
you must create a textbox called text1 and make sure its big
enough so its not too fiddly to drop a file onto











( oledragdrop.html )- by Paolo Puglisi - Modifica del 17/12/2023