README.md

December 5, 2022 ยท View on GitHub

simple drag drop file textbox

Description

drag and drop files into a textbox is simple with this code

More Info

Submitted On
Bycold_postage
LevelBeginner
User Rating4.5 (18 globes from 4 users)
CompatibilityVB 6.0, VB Script
CategoryCoding Standards
WorldVisual Basic
Archive File

Source Code

create a textbox on an empty form
in the property window of the textbox change the OLEDropMode to "Manual".
now add this function to your form code:

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

If Data.GetFormat(vbCFFiles) Then Text1.Text = Data.Files(1)

End Sub
add the following if you don't want to show the drag drop mouse pointer when the item is not a file
Private Sub Text1_OLEDragOver(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single, State As Integer)

If Not Data.GetFormat(vbCFFiles) Then Effect = vbDropEffectNone

End Sub