Results 1 to 6 of 6

Thread: Drag & Drop

  1. #1

    Thread Starter
    Fanatic Member Gary.Lowe's Avatar
    Join Date
    May 2000
    Location
    In my sphere of influence
    Posts
    621

    Unhappy

    Hi All

    How do I drag a file onto a text box and display the files path and name in the text box.

    Cheers
    Gary Lowe
    VB6 (Enterprise) SP5
    ADO 2.6
    SQL Server 7 SP3

    OK I know my spelling and grammer is crap so don't quote me on it!

    To err is human to take the P! is only natural !!

    Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip


  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Set the OLEDropMode property of the TextBox to 1 Manual, then use this:
    Code:
    Private Sub Text1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
        Dim varFiles As Variant
        
        On Error Resume Next
        
        For Each varFiles In Data.Files
            Text1.Text = Text1.Text & varFiles & vbCrLf
        Next
    End Sub
    This will allow you to drag multiple files as well.

  3. #3

    Thread Starter
    Fanatic Member Gary.Lowe's Avatar
    Join Date
    May 2000
    Location
    In my sphere of influence
    Posts
    621
    Thanks Serge

    That works fine but leaves two characters at the end
    Code:
    C:\WINNT\Profiles\loweg\Desktop\test.lf
    Gary Lowe
    VB6 (Enterprise) SP5
    ADO 2.6
    SQL Server 7 SP3

    OK I know my spelling and grammer is crap so don't quote me on it!

    To err is human to take the P! is only natural !!

    Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip


  4. #4

    Thread Starter
    Fanatic Member Gary.Lowe's Avatar
    Join Date
    May 2000
    Location
    In my sphere of influence
    Posts
    621
    Serge
    It doesn't disply them on the previous post but it leaves two bold lines on the end.

    Do you know anyway to stop this?

    Thanks
    Gary Lowe
    VB6 (Enterprise) SP5
    ADO 2.6
    SQL Server 7 SP3

    OK I know my spelling and grammer is crap so don't quote me on it!

    To err is human to take the P! is only natural !!

    Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip


  5. #5
    Lively Member
    Join Date
    Sep 1999
    Location
    Liverpool, UK
    Posts
    64
    Set the OLEDropMode to Manual and the MultiLine property on the text box to TRUE, and try this....

    Code:
    Private Sub Text1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Data.Files.Count > 0 Then
        For z = 1 To Data.Files.Count
            Text1.Text = Text1.Text + Data.Files(z) + vbNewLine
        Next z
    End If
    End Sub

  6. #6

    Thread Starter
    Fanatic Member Gary.Lowe's Avatar
    Join Date
    May 2000
    Location
    In my sphere of influence
    Posts
    621

    Cool

    Thanks joefoulkes

    works fine now
    Gary Lowe
    VB6 (Enterprise) SP5
    ADO 2.6
    SQL Server 7 SP3

    OK I know my spelling and grammer is crap so don't quote me on it!

    To err is human to take the P! is only natural !!

    Click on the top section of image for Marcus Miller website and bottom section of image for 'Run For Cover' sound clip


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width