Für dieses Beispiel brauchen Sie ein Formular, eine Listbox (List1) und eine Textbox (Text1).
Private Sub Form_Load()
'Ausrichtung der Listbox, Textbox
List1.Move 120, 120, 6000, 2000
Text1.Move 120, 2200, 6000, 2000
List1.OLEDropMode = 1
Text1.OLEDropMode = 1
' Kann nicht während der Laufzeit eingestellt werden:
'Text1.MultiLine = True
End Sub
Private Sub List1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim I As Integer
' Pfad in die Liste einfügen
If Data.GetFormat(vbCFFiles) Then
For I = 1 To Data.Files.Count
List1.AddItem Data.Files.Item(I)
Next I
End If
End Sub
Private Sub Text1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim I As Integer
Dim f As Long
' Textdatei öffnen und einlesen
If Data.GetFormat(vbCFFiles) Then
f = FreeFile
Open Data.Files.Item(1) For Input As f
Text1.Text = Input(LOF(f), f)
Close f
End If
End Sub