Solved

VB6 - Drag and drop file/s onto a textbox

Posted on 2006-06-23
2
870 Views
Last Modified: 2010-08-05
Hello.  I have a text box, and I'd like to be able to drag a file from windows explorer onto it, and have the text box show the full path of the file after it is dropped on there.  It's easy to do this in .NET, but I'm not sure how to do it in VB6.  It would be nice to know how to extract the path of multiple files dragged onto it, though for my use this time only 1 is necessary.  Does anyone know how to do this?

Thanks.
0
Comment
Question by:prosh0t
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
Comment Utility
(the TextBox has MultiLine set to True)

Option Explicit

Private Sub Form_Load()
    Text1.OLEDropMode = 1 ' Manual
    Me.OLEDropMode = 1 ' Manual
End Sub

Private Sub Form_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Data.GetFormat(vbCFFiles) Then
        Dim sText As String
        Dim i As Integer
        For i = 1 To Data.Files.Count
            sText = sText & Data.Files(i) & vbCrLf
        Next
        Text1.SelText = sText
    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)
    Call Form_OLEDragDrop(Data, Effect, Button, Shift, X, Y)
End Sub
0
 
LVL 7

Author Comment

by:prosh0t
Comment Utility
Thanks!  Worked perfectly..
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now