473,889 Members | 1,322 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 9736
blurryanthem
43 New Member
Hello Sir Geur,

I think I've made it work as to what I need with the tool. Please take a check with its functionality and see if there are still areas that are buggy or needs improvement.

Thank you so much for your unselfish help. I was able to learn alot while studying your codes at the same time and was able to refresh my vb knowledge that has been stucked for 5 years now.

Attached is the tool.

Thanks alot!
Emily
Attached Files
File Type: zip File Replicator ver. 2.zip (13.6 KB, 74 views)
Jan 13 '11 #51
blurryanthem
43 New Member
I just found a bug wherein if a copy process is ongoing and a file exist halfway the process and then I press cancel... the copy process was stopped but the progress bar does not go back to zero.

I tried to insert the lines below but program does not seem to read it..I don't know why.

Expand|Select|Wrap|Line Numbers
  1.          If MESSAGE = vbCancel Then Exit Sub
  2.           ShapeProgress.Width = 0
  3.           LabelProgress.Caption = "Copy Cancelled."
  4.          If MESSAGE = vbNo Then GoTo NextFile
  5.          FileCopy Text1(STARTFILEidx), SaveTo.Text & "\" & FILETO
  6.  
Jan 13 '11 #52
Guido Geurs
767 Recognized Expert Contributor
Resetting the progressbar must be done before You Exit the Sub:

Expand|Select|Wrap|Line Numbers
  1.          If MESSAGE = vbCancel Then
  2.             LabelProgress.Caption = "Copy Canceled."
  3.             ShapeProgress.Width = 0
  4.             Exit Sub
  5.          End If
When I click Log then Notepad opens but Minimized.
I have changed the code to :
Expand|Select|Wrap|Line Numbers
  1. Private Sub ComShowLog_Click()
  2. Dim NOTEPADSHELL As Double
  3.    NOTEPADSHELL = Shell("Notepad " & SaveTo.Text & "\Log.txt", vbNormalFocus)
  4. End Sub
In my code is the progressbar working (see attachment).
Is in Your code the indication Shape on top of the background of the progressbar?

I have also added in the log the type of copy: "replaced" or "New" and "Canceled" if so.

I don't understand Your previous mail in which You say: "the situation wherein no destination drive is specified, since ..."
and You modify the code for no files dropped = "If Text1.Count = 1 Then
MsgBox "There ..." ???

and I think there is an error in it because You "Exit it" when there are files dropped: (if Count = 1 => Msg
ELSE => Exit sub ...)

" If Text1.Count = 1 Then
MsgBox "There ...
Else
Exit Sub
End If

PS:
It was a pleasure helping You because I learn more by working and searching for solutions on an existing problem than reading 10 books of programming.
If You have still questions, please don't hesitate and place them in a call on Bytes.
Jan 13 '11 #53
blurryanthem
43 New Member
Sir Geur,

The progress bar is goes back to 0 when copy is canceled. So you just have to put the conditions before exiting sub. Tnx!

As for the code below..I am quite hesitant to use it as after I replicate files..and click log file button using your code below since it only opens an empty file..but does not write the copied files on the Log.text
Expand|Select|Wrap|Line Numbers
  1.    1. Private Sub ComShowLog_Click()
  2.    2. Dim NOTEPADSHELL As Double
  3.    3.    NOTEPADSHELL = Shell("Notepad " & SaveTo.Text & "\Log.txt", vbNormalFocus)
  4.    4. End Sub
  5.  
At the end of my replicate button code I have already indicated that a log file should be printed. I put this after files are successfully replicated. I will by default print and save the Log file at c:\Log.txt
Expand|Select|Wrap|Line Numbers
  1.             '§ print Log
  2.             sFilename = "c:\Log.txt"
  3.  
  4.             'obtain the next free file handle from the
  5.             'system and and save the text box contents
  6.             hFile = FreeFile
  7.             Open sFilename For Output As #hFile
  8.             Print #hFile, LOGTEXT
  9.             Close #hFile
  10.  
  11.  
I would only need the filenames ( a new or replaced file does not matter ). Is there also a way to indicate the total number of files being copied? I assume by couting the lines in the saved file? How?
Jan 13 '11 #54
Guido Geurs
767 Recognized Expert Contributor
The total of different files to copy= TextFiles.Count-1 (-1 for the original textbox with index= 0)
The total of copyed files is already calculated for the progress bar= COPYTOTAL
In:
Expand|Select|Wrap|Line Numbers
  1.    For COPIESidx = 1 To TextFiles.Count - 1
  2.       COPYTOTAL = COPYTOTAL + Val(CopyTimes(COPIESidx))
  3.    Next
Jan 14 '11 #55
blurryanthem
43 New Member
Hello Sir Geur,

It's just now that I have noticed that hung up. There seems to be a problem when copying large number of copies per chosen file. The tool seems to hung up and does not anymore show all the progress and then after a while immediately goes to 100%.

I'm unsure if this can handle thousand of copies?
Any help?

Thank You!
Jan 17 '11 #56
blurryanthem
43 New Member
Sir Geur,

I also want to understand your code below as when clicked, it seems to ask the user to create Log file. And then when confirmed, it creates an empty Log file. It doesn't write the filenames to the Log.txt. What does it really do? Just open and create an empty Log.txt?

Expand|Select|Wrap|Line Numbers
  1. Private Sub ComShowLog_Click()
  2. Dim NOTEPADSHELL As Double
  3. NOTEPADSHELL = Shell("Notepad " & SaveTo.Text & "\Log.txt", vbNormalFocus)
  4. End Sub
  5.  
I have indicated in the last lines of my code at Replicate button this:
Expand|Select|Wrap|Line Numbers
  1.             '§ print Log
  2.             sFilename = "c:\Log.txt"
  3.  
  4.             'obtain the next free file handle from the
  5.             'system and and save the text box contents
  6.             hFile = FreeFile
  7.             Open sFilename For Output As #hFile
  8.             Print #hFile, LOGTEXT
  9.             Close #hFile
  10.  
Jan 17 '11 #57
Guido Geurs
767 Recognized Expert Contributor
Q1 : maybe there are to much copies at the same time.
Is the problem solved if You enter the "Doevents" after the copy command like this:
Expand|Select|Wrap|Line Numbers
  1. .....
  2.          If MESSAGE = vbNo Then GoTo NextFile
  3.          FileCopy TextFiles(STARTFILEidx), SaveTo.Text & "\" & FILETO
  4.          DoEvents
  5.          '§ add filename for printing log
  6.          If FILEEXIST Then
  7. .....
  8.  
Q2: My code opens notepad to a logfile I make in the destination folder (SaveTo.Text).

Expand|Select|Wrap|Line Numbers
  1. Private Sub ComShowLog_Click() 
  2. Dim NOTEPADSHELL As Double 
  3. NOTEPADSHELL = Shell("Notepad " & SaveTo.Text & "\Log.txt", vbNormalFocus) 
  4. End Sub 
If Your Logfile is = "c:\Log.txt " (there is no logfile created by Your code in the copy-to folder) then the code must be:
Expand|Select|Wrap|Line Numbers
  1. Private Sub ComShowLog_Click() 
  2. Dim NOTEPADSHELL As Double 
  3. NOTEPADSHELL = Shell("Notepad c:\Log.txt", vbNormalFocus) 
  4. End Sub 
Jan 17 '11 #58
blurryanthem
43 New Member
Hello Sir Geur,

I just noticed that a Run time error '75', Path/File access error is being thrown when I am trying to replicate/copy files into an empty/formatted external drive( ex. usb flash drive)

But when the same flash drive has at least a file in it, then replicate/copy files to the drive using the tool...no error is thrown and normal copy process is performed.

When the error "75" occured, it seemed to point at this line:

If Dir$(PATHpart, vbDirectory) = "" Then MkDir (PATHpart) '§ create folders

Any idea why?
Thanks
Emily
Feb 10 '11 #59
Guido Geurs
767 Recognized Expert Contributor
The previous code checks only on Folders.
If you want to copy to the root, the code "Dir$(PATHp art, vbDirectory)" gives an error because it's a root and not a vbDirectory !
If it's an existing root, go directly to the copy code.
I have changed it to check drive, root and folders (see attachment).
Feb 10 '11 #60

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

Similar topics

1
1919
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
2
4344
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?
1
1679
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
5
10174
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
0
1787
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?
1
8536
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
1
2917
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...
16
11875
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...
0
1309
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...
0
9961
marktang
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...
0
9807
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,...
0
10789
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10889
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7993
isladogs
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...
0
7150
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6028
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4647
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
3
3255
bsmnconsultancy
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.