wzm
asked on
Drag & Drop
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.
I would like to drag a text file onto a text box.(content of text file).I wonder how..
Thank U very Much
w.
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.
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.
ASKER
Glass Cookie - Nop I don't know (load a text file) - Please
share with me, Thanks
share with me, Thanks
ASKER
Glass Cookie - Nop I don't know (load a text file) - Please
share with me, Thanks
share with me, Thanks
OK... code coming up... (gimmie a few min...)
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 : )
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 : )
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
Text1 > OLEDragMode set to 1 - Automatic, OLEDropmode set to 1 - Manual
Private Sub MyTextbox_OLEDragDrop(Data
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You Deserved it Guru.
Private Sub Form_Load()
RichTextBox1.OLEDragMode = rtfOLEDragManual
RichTextBox1.OLEDropMode = rtfOLEDropManual
End Sub
Private Sub RichTextBox1_OLEDragDrop(D
RichTextBox1.LoadFile Data.Files(1)
End Sub