0

After the first listProcess.items.add, the listProcess listbox doesn't refresh. Basically, just populating one listbox from another, as directories get copied. Just trying to show a status of which copy is being done. Neither of the refreshes seem to work. This is too simple to be stumping me. Thanks in advance.

While ix < listSaveFolders.Items.Count
        listProcess.Items.Add(listSaveFolders.Items.Item(ix))
        listprocess.refresh
        Me.Refresh()
            My.Computer.FileSystem.CopyDirectory(CStr(listSaveFolders.Items.Item(ix)),  bk_dir_top & get_folder_end(ix), True)
    End While
Tim Williams
  • 154,628
  • 8
  • 97
  • 125
Paul
  • 3
  • 2

2 Answers2

0

A While loop without condition state change ?

While ix < listSaveFolders.Items.Count
    listProcess.Items.Add(listSaveFolders.Items.Item(ix))
    'listprocess.Refresh()
    'Me.Refresh()
    My.Computer.FileSystem.CopyDirectory(CStr(listSaveFolders.Items.Item(ix)), bk_dir_top & get_folder_end(ix), True)

    ix = ix + 1 ' <- here !
    ' I've disabled the .Refresh() but you can put back one of them
    ' here if you want.
End While

Edit : reverted back a pending edit. Was just not really waken up. Sorry.

Karl Stephen
  • 1,120
  • 8
  • 22
0

You could use Application.DoEvents instead of Me.Refresh or listProcess.Refresh, which should update/refresh the ListBox after you add a new item.

If you're looking for a more "complex" solution, take a look at BackgroundWorker and this question.

Also, you're not updating the ix variable, thus creating an endless loop.

Community
  • 1
  • 1
Stijn
  • 1,970
  • 3
  • 27
  • 36
  • Thank you. I just starting reading about backgroundworker. (I deleted the ix+=1 when I cut the code to send in.) I'll try the application.doevents also. – Paul Nov 19 '14 at 13:11