Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Drag & Drop

Posted on 2001-06-21
9
Medium Priority
?
246 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
[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
  • 5
  • 3
9 Comments
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 6216738
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
ID: 6216780
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
ID: 6217347
Glass Cookie - Nop I don't know (load a text file) - Please
share with me, Thanks
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

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

Expert Comment

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

Expert Comment

by:glass_cookie
ID: 6220971
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
ID: 6220989
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 200 total points
ID: 6220991
If you're accepting my ans, please try to give an 'A' as much as possible : )
0
 

Author Comment

by:wzm
ID: 6222968
You Deserved it Guru.
0

Featured Post

Industry Leaders: 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

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…
Suggested Courses

636 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