Results 1 to 4 of 4

Thread: Label showing Files in a Dir

  1. #1

    Thread Starter
    Hyperactive Member Emo's Avatar
    Join Date
    Jul 2000
    Posts
    428

    Question

    Ok, I want to make a funny program to scare my friend , but I need some help. I want to do so when they press a command button, a label that is on the form, will show every file in a desired directory. And I want it to show the files really fast so it looks like it's deleting the files from there, but it's actually not doing anyting harmful to the dir...
    Any Help would be great!
    Thanks!
    -Emo
    -=VB6 Enterprise Edition=-
    -=VC++6Enterprise Edition=-
    «¤E³m°O²™¤»

  2. #2
    Guest
    Code:
    Needed: FileListBox, Command Button, Label
    
    Private Sub Command1_Click()
    On Error Resume Next
    For i = 0 to File1.ListCount
    Label1.caption = File1
    File1.ListIndex = File1.ListIndex + 1
    Next i
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member Emo's Avatar
    Join Date
    Jul 2000
    Posts
    428

    Smile Thnaks, but...

    Thanks for the reply, but it has some side effects... the first thing, is that if I move my mouse while it's listing(deleting) the files, they speed up. Now this is not that big problem, but at the end, the command button renames it self to the last file in the List1...
    Do you know how can I fix this?
    Thanks!
    -Emo
    -=VB6 Enterprise Edition=-
    -=VC++6Enterprise Edition=-
    «¤E³m°O²™¤»

  4. #4
    Guest
    Code:
    Private Sub Command1_Click()
    On Error Resume Next
    For i = 0 to File1.ListCount
    Label1.caption = File1
    File1.ListIndex = File1.ListIndex + 1
    Next i
    Command1.caption = File1
    End Sub
    If you'd rather have it listing the files you are "deleting":

    Code:
    Needed:  Listbox, Command Button, Label
    
    Dim FileFinder
    FileFinder = Dir("C:\Windows\*.*")
    Do Until FileFinder = ""
    List1.AddItem LCase("C:\Windows\" & FileFinder)
    Label1.Caption = "Deleting " & FileFinder & "....."
    FileFinder = Dir
    DoEvents
    Loop
    Label1.Caption = "C:\Windows\*.* - DELETED!"
    If you want it a bit slower, but a bit faster:

    Code:
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    
    Private Sub Command1_Click()
    Dim FileFinder
    FileFinder = Dir("C:\Windows\*.*")
    Do Until FileFinder = ""
    List1.AddItem LCase("C:\Windows\" & FileFinder)
    Label1.Caption = "Deleting " & FileFinder & "....."
    FileFinder = Dir
    DoEvents
    Sleep 30
    Loop
    Label1.Caption = "C:\Windows\*.* - DELETED!"
    End Sub

    [Edited by Matthew Gates on 07-31-2000 at 11:06 PM]

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