Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

VB6 - Drag and drop file/s onto a textbox

Posted on 2006-06-23
2
874 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
ID: 16971097
(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
ID: 16973194
Thanks!  Worked perfectly..
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

856 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