Solved

Drag & Drop

Posted on 2001-06-21
9
224 Views
Last Modified: 2010-05-02
Hi All,

  I would like to drag a text file onto a text box.(content of text file).I wonder how..


Thank U very Much
w.







0
Comment
Question by:wzm
  • 5
  • 3
9 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
Comment Utility
Hi wzm, the easier way is use the Rich Text Box Control rather than Text Box Control:

Private Sub Form_Load()
    RichTextBox1.OLEDragMode = rtfOLEDragManual
    RichTextBox1.OLEDropMode = rtfOLEDropManual
End Sub

Private Sub RichTextBox1_OLEDragDrop(Data As RichTextLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
    RichTextBox1.LoadFile Data.Files(1)
End Sub
0
 
LVL 8

Expert Comment

by:glass_cookie
Comment Utility
Hi!

Do this:

Download...
http://www.vb-helper.com/Howto/oledrop.zip
Description: Process files dragged onto a form (2K)

Use this code for the textbox instead.  The only problem is that you'll have to figure whatever 2 OLE dragdrop properties that you'll have to set.  I think it's Manual then Automatic.

Load the file upon getting the filepath.

That's it!

glass cookie : )

PS. I assume you know how to load a text file.
0
 

Author Comment

by:wzm
Comment Utility
Glass Cookie - Nop I don't know (load a text file) - Please
share with me, Thanks
0
 

Author Comment

by:wzm
Comment Utility
Glass Cookie - Nop I don't know (load a text file) - Please
share with me, Thanks
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 8

Expert Comment

by:glass_cookie
Comment Utility
OK... code coming up... (gimmie a few min...)
0
 
LVL 8

Expert Comment

by:glass_cookie
Comment Utility
Here's the code...

Dim F As Integer
F = FreeFile
Open "C:\MyFile.txt" For Input As #F
MyTextbox.Text = Input(LOF(1), 1)
Close F
End If

where "C:\MyFile.txt" is the filepath of your file, MyTextbox is the dstination textbox to stuff all the text to and you can replace it with some other control like Label1.Caption or just a string.

That's it!

glass cookie : )

PS. Happy programming : )
0
 
LVL 8

Expert Comment

by:glass_cookie
Comment Utility
Here's how the code should be:

Text1 > OLEDragMode set to 1 - Automatic, OLEDropmode set to 1 - Manual

Private Sub MyTextbox_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)

Dim txt As String
Dim fname As Variant

For Each fname In Data.Files
txt = txt & fname & vbCrLf
Next fname
'MsgBox txt '-Show filepath

Dim F As Integer
F = FreeFile
Open txt For Input As #F
MyTextbox.Text = Input(LOF(1), 1)
Close F
End If

' Indicate we did nothing with the files.
Effect = vbDropEffectNone

End Sub
0
 
LVL 8

Accepted Solution

by:
glass_cookie earned 50 total points
Comment Utility
If you're accepting my ans, please try to give an 'A' as much as possible : )
0
 

Author Comment

by:wzm
Comment Utility
You Deserved it Guru.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now