473,842 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to drag drop file/s into a textbox from winexplorer?

43 New Member
Hello , I'm trying to drag drop file/s into a textbox from windows explorer using vb6. I can't figure it out how to create textboxes at runtime depending on how many file selection did I make for dragdrop purposes. Is there a way to do that in vb6 and how?

Thanks alot and happy holidays.
Dec 22 '10
64 9727
43 New Member
Sir Geurs,

Thanks alot, I used "drag drop files into a textbox from winexplorer_v1. 1.zip" as I prefer a textbox in my form. I loaded a checkbox as well using the same control array with the textboxes created at runtime.

The checkbox will be used later on to select final files for removal or replication ( in case the user mistakenly dragged/dropped a file ).

Can I use the same control array as my counter to be able to remove/replicate "checked" files? It will be easier to indicate them in checkboxes and provide only 1 REMOVE and REPLICATE button for the file manipulation.

Creation of textboxes and checkboxes at run time:
Expand|Select|Wrap|Line Numbers
  1. Private Sub DropArea_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
  2. Dim i As Integer
  3. Dim dCount As Integer
  5.       On Error GoTo No_File_info
  6.       i = Text1.Count - 1
  8.       For dCount = 1 To Data.Files.Count
  10.          Load Text1(i + dCount)
  11.          With Text1(i + dCount)
  12.             .Top = Text1(i + dCount - 1).Top + Text1(0).Height
  13.             .Text = Data.Files.Item(dCount)
  14.             .Visible = True
  15.          End With
  17.          Load NumEntryBtn(i + dCount)
  18.          With NumEntryBtn(i + dCount)
  19.             .Top = NumEntryBtn(i + dCount - 1).Top + NumEntryBtn(0).Height
  20.             '.Text = i + dCount
  21.             .Visible = True
  22.          End With
  24.         Load CheckBtn(i + dCount)
  25.         With CheckBtn(i + dCount)
  26.             .Top = CheckBtn(i + dCount - 1).Top + CheckBtn(i + dCount - 1).Height
  27.             .Visible = True
  28.         End With
  30.       Next
  31.       FrameSlide.Height = Text1.Count * Text1(0).Height
  32.       If FrameSlide.Height > FrameFix.Height Then
  33.          With VScrollFiles
  34.             .Max = (FrameSlide.Height - FrameFix.Height) / 10
  35.             .SmallChange = 200
  36.             .LargeChange = FrameFix.Height / 10
  37.             .Visible = True
  38.          End With
  39.       Else
  40.          VScrollFiles.Visible = False
  41.       End If
  42. Exit Sub
  43. No_File_info:
  44.    MsgBox "No File name from Explorer"
  45. End Sub

Unload Checkbx, Textbox corresponding to that checked checkbox in the array:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Clear_Click()
  2. Dim i As Integer
  4.         For i = 1 To CheckBtn.Count
  5.             If CheckBtn(i).Value = vbChecked Then
  6.             Unload Text1(i)
  7.             Unload NumEntryBtn(i)
  8.             Unload CheckBtn(i)
  9.             End If
  10.         Next
  12. End Sub
Is this correct?
Dec 30 '10 #21
43 New Member
Sir Geurs,

You think this is better?

Dec 30 '10 #22
Guido Geurs
767 Recognized Expert Contributor
Looks OK but one question:
Why add a checkbox ? You can use a pop-up menu like in attachment v1.2.
One problem: if You delete a textbox, the index of the boxes will not be continues any more!! => how to program which indexes still exist and which not ???
There is also in the code the count used textboxes (= textbox.count) :o( to calculate the indexes for the next drop !
There is an other way: move the data one box up and delete the last textbox ?

I have also attached a new ZIP with the 2.1 version: it works on my PC (with XP Pro SP 3 and VB6 SP6)
Dec 30 '10 #23
Guido Geurs
767 Recognized Expert Contributor
attached v1.3 with delete and scroll-up of the data.
Use LMB on the textbox to delete (to pop-up the delete menu).
Dec 30 '10 #24
43 New Member
Sir Geur,

I think that a checkbox is for ease selection of which file to delete and replicate.

I have tried your v1.3 ( with delete and scroll-up of the data ) and deletion was not a problem. Although, I'm seeing that it would be a bit tedious for the user to manually click each of the files that needs to be deleted. While if we use checkbox, we will only hit one "remove/delete" button for all selected files ( w. checked checkboxes).

Do you agree?

Because the next thing that I would work here is the replicate to x times command.
Dec 30 '10 #25
Guido Geurs
767 Recognized Expert Contributor
I think there are 2 types of deletion:
The PUmenu delete is only used for deletion of a file the user don't want replicate (has been dropped by mistake)
A button with delete for clearing the boxes with the code=
Expand|Select|Wrap|Line Numbers
  1. For i=1 to textfiles.count
  2.   unload textfiles(i)
  3.   unload texttimes(i)
  4. next
This way You don't need the checkboxes !
Dec 31 '10 #26
43 New Member
Hello Sir Geur,

I've followed your suggestion about the pop up menus instead of checkboxes. This makes it alot easier now to select which files to delete if added mistakenly. This way the remaining files will be by default all the ones which should undergo the replication process.

I would like to ask though if there is a way in VB to save the selected files by by extracting the filenames from the full directory path? Then save it by listing.

C:\dell\drivers \R182522\Help.t xt ( ex. 5x to be copied)
C:\dell\drivers \R182522\test.d ll ( ex. 3x to be copied)

Save this selected file to a specified directory with filename:


I can't seem to extract the filename itself other than assigning a fix filename with index to all copied files..which is not helping. Any help Sir Geur?

Jan 3 '11 #27
Guido Geurs
767 Recognized Expert Contributor
You can extract the filename from the path by cutting the string after the last "\" with:

Expand|Select|Wrap|Line Numbers
  1. FILENAME = Mid(TextFiles(xx),Instrrev(TextFiles(xx),"\")+1)
For adding an index: cut the FILENAME before and after the last "." like:

Expand|Select|Wrap|Line Numbers
  1. NAME = Left(FILENAME,Instrrev(FILENAME,".")-1)
  2. EXTENTION = Mid(FILENAME,Instrrev(FILENAME,".")+1)
Recombine the destination filename with index:

Expand|Select|Wrap|Line Numbers
  1. FILETO = NAME & "(" & index & ")" & EXTENTION
Jan 5 '11 #28
43 New Member
Sir Geur,

Does TextFiles(xx) stand for the textbox with the fullpath and file name in my prog? And does (xx) stand for it's array? All about this get filename is on one function right not part of the Replicatebtn_cl ick() sub?

like in my code:

For i =1 To Text1.count
FILENAME = Mid(Text1(i),In strrev(Text1(i) ,"\")+1)

In my ReplicateBtn_cl ick() , can I use the FileCopy? like

FileCopy Text1.Text, SaveTo.Text

Is this correct?
Jan 5 '11 #29
43 New Member
I have actually asked the same thing for the replication process. I'm still really learning from this VB thing in which I am trying to enhance the old tool.

Jan 5 '11 #30

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Oleg Medyanik | last post by:
Hi, Is there any way to drag-drop messages from Outlook 2003 into my Application (.NET based) I have not found it googling yet. The problem is that i want the messages to preserve their MSG format, not just get their text. (it should look like you've dropped message to MS Word). Any help is appreciated. Thanks you
by: SamSpade | last post by:
There seems to be two ways to put things on the clipboard ( I don't mean different formats): SetClipboardData and OleSetClipboard If I want to get data off the clipboard do I care how it was put there? What about Drag/Drop; is there more than one way for the source to make data available Is it always OLE?
by: Marco Zender | last post by:
Hello, i'm in real trouble and don't know how to handle it! May someone can give me a hint? Following problem: In my application you can drag&drop a file from the explorer. In my application this file will be encrypted and then you should be able to drag&drop the file from the application to the explorer. How can i code the last step ?!? I have tried it with DoDragDrop but without success :-( TIA
by: Brian Henry | last post by:
I haven't worked much with drag/drop but I am trying to make a form that accepts files to drug onto it from explorer and droped and have the form know the full path and file name of the files dropped onto it.. does anyone have any examples of this? thanks
by: Pesso | last post by:
I'm loading a text file to a RichTextBox control to drag a selection of a text and drop it into a tree view control. It works except after the drag and drop operation the RichTextBox scrolls to the top. This is very inconvenient because after the drag-drop operation the user has to scroll down to where he was before. Is there anyway to make the RichTextBox stop jumping to the top after a drag-drop from it?
by: John Devlon | last post by:
Hi I would like to create a file upload system, using file drag and drop functionality. Does anyone know how ? John
by: Steve Bottoms | last post by:
Hi, all! Using VB .Net 2k5 under Vista Business... I'm trying to put together a very basic drag-and-drop for file copying, and can't seem to get DragDrop events (Form, PictureBox, TextBox, etc) to fire at all, and DragEnter only fires if the drag operation STARTS on the form (kinda defeating the purpose of a drag-and-drop file copier). Is there some trick to getting it to work? I've tried several different samples from MSDN and this...
by: John | last post by:
I am looking for VBA code that will work with Access 2003 to enable dragging and dropping a file/folder name from Windows XP Explorer into an Access form's text box. This is a common functionality that most Windows programs have, so I'm suprised it's not easier to implement in Access/VBA. Through Google, I found two VB6 examples and one VBA example on the Access Web written by Dev Ashish. The VB6 examples used loops to keep checking...
by: babai28 | last post by:
Hi, I have a situation where in a winform application I have a tree view from which I need to drag drop tree nodes into a textBox contained in another application window. I used the following code to handle the drag dragEnter and the dragDrop event of the textBox: private void txtTrue_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(TreeNode))) { //Create a New...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.