?
Solved

VB6 drag and drop: grab file name and path into textbox

Posted on 2010-01-04
2
Medium Priority
?
3,378 Views
Last Modified: 2012-05-08
Dear Experts,

I would like to drag and drop a file/folder from Windows Explorer into a standard textbox, and have the file name and path appear.  I am using manual drag and drop.  So I guess I need a way of converting Data.GetData(vbCFFiles) into text format. The Str() function does not work.

Thanks!
0
Comment
Question by:ttobin333
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 26173760
Try something like:
Option Explicit

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

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
        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

Open in new window

0
 

Author Closing Comment

by:ttobin333
ID: 31672517
Perfect! Thanks Idle_Mind!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

807 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