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

        Label2.Text = "before"
        Sleep(3000)
        Label1.Text = "after"

    End Sub

When i click the button1, the above code executes. Actually i should display label2 with string "before" and after 3 seconds label1 with string "after". But this is not happening both the labels with name "before" and "after" are displaying after 3 seconds after the form loads and also both the labels are displaying at once.

please solve my problem.

3
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by ravikiran032
0

hello adapost, but when i click on button,first label text doesn't change to before,But sleep is working, & after some seconds label text is chnage to after

Imports System.Threading
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Label1.Text = "before"
            Thread.Sleep(10000)
            Label1.Text = "after"
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub
End Class

hi ravikiran032,thread.sleep takes time in milliseconds...remember it

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.