Help a Beginner

I cannot understand why the following code does not show label1.text until the copy has comleted. It then shows label1.tex t= "All Copied"

I am expecting "Please wait" until the copy is complete.

Any help appreciated

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim pathtobackup As String

Dim datenow As String

Label1.Visible = True

datenow = (Format(Now, "dddd, d MMM yyyy"))

'Backup MyDocuments Folder then MyFavourites

Label1.Text = "Please Wait"

pathtobackup = "D:\backup\64BitBackup\" & datenow & "\My Documents"

If CheckBox1.Checked = True Then

My.Computer.FileSystem.CopyDirectory("C:\Documents and Settings\The Pict\My Documents", pathtobackup, True)

End If

pathtobackup = "D:\backup\64BitBackup\" & datenow & "\Favourites"

If CheckBox1.Checked = True Then

My.Computer.FileSystem.CopyDirectory("C:\Documents and Settings\The Pict\Favorites", pathtobackup, True)

End If

Label1.Text = "All Copied"

End Sub



Answer this question

Help a Beginner

  • RichardD

    Try putting a DoEvents() after each of the label text changes.

    BobP



  • cjjrmj

    Thank you

    That is working well


  • Old John

    The correct syntax would be:

    Application.DoEvents()

    If you put it after the label text change, you should see the label update.

     

    BobP



  • hotentote

    If I place DoEvents() before label1.text= "Please Wait" I get an exeption.

    Can you explain the syntax as the help is far too advanced for me

    Thanks in advance


  • Help a Beginner