Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB6 - Drag and drop file/s onto a textbox

Posted on 2006-06-23
2
Medium Priority
?
893 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
[X]
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
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

719 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