Results 1 to 4 of 4

Thread: A drag & drop ?

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 1999
    Location
    Skudeneshavn, Norway
    Posts
    38
    Hi

    I have a listbox, with filenames
    and when i click on a filename from
    the listbox i want the File1 in the code
    below to be replaced with the filename
    from the listbox in the drop.


    Dim Oldname
    Dim Newname
    Oldname = Dir1.Path & "\" & File1
    Newname = Dir1.Path & "\" & List1
    Name Oldname As Newname
    File1.Refresh

    Can someone please help me with this
    question.

    Thanks


    Chris Davidsen
    Christian Davidsen

    If you go to sleep with an itchy
    ass, you wake up with smelly fingers.

  2. #2
    Lively Member
    Join Date
    Aug 2000
    Posts
    125
    Dim Oldname
    Dim Newname
    Oldname = Dir1.Path & "\" & File1.filename
    Newname = Dir1.Path & "\" & List1.List(List1.ListIndex)

    Name Oldname As List1.List(List1.ListIndex)
    FileCopy Newname, Oldname
    File1.Refresh


  3. #3
    Guest
    Ok, I kind of got it, but you have to make sure a file is selected in the FileListBox.

    Code:
    'Author: Megatron
    'Origin: http://forums.vb-world.net
    'Purpose: Drag one list to the other 
    'Version: VB4+ 
    'Comments (from me):  Paying my respects and giving credit where it is needed, very good code as well
    
    Dim StartDrag As Boolean
    
    Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        StartDrag = True
        strTemp = List1.Text
    End Sub
    
    Private Sub List2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If StartDrag = True Then
            List2.AddItem List1.Text
            List1.RemoveItem List1.ListIndex
        End If
        StartDrag = False
    End Sub
    Took me a while to figure this out, but I think I may have found it:

    Code:
    Dim StartDrag As Boolean
    
    Private Sub File1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim Oldname
    Dim Newname
        If StartDrag = True Then
        Oldname = Dir1.Path & "\" & File1
        Newname = Dir1.Path & "\" & List1
        Name Oldname As Newname
        File1.Refresh
        End If
        StartDrag = False
    
    End Sub
    
    Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        StartDrag = True
    End Sub

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 1999
    Location
    Skudeneshavn, Norway
    Posts
    38

    wropng number of argument??

    Hi

    I tried your code

    amd my code looks like this
    --------------------------------------
    Dim Oldname
    Dim Newname

    For i = 0 To List1.ListCount
    Label1 = i

    Oldname = Dir1.Path & "\" & File1.List(i).filename
    Newname = Dir1.Path & "\" & List1.List(i)

    Name Oldname As Newname

    Next i
    ---------------------------------------


    but it does not like File1.List(i), wrong argument

    do you have any other clues

    Thanks


    Chris Davidsen
    Christian Davidsen

    If you go to sleep with an itchy
    ass, you wake up with smelly fingers.

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