By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,219 Members | 2,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,219 IT Pros & Developers. It's quick & easy.

using delay in vb.net

P: n/a
hi friends,
I want to know how can we insert delay in vb.net
like.....
i want to show two strings on same label
first one string then break of 5 secs and then second string
how can i acheive this?
i mean label should show first
label.text("before")
then it should wait for 5 secs and then it should show
label.text("After")

thanks
Amit
Nov 20 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
"AmitTrehan" <am************@hotmail.com> schrieb
hi friends,
I want to know how can we insert delay in vb.net
like.....
i want to show two strings on same label
first one string then break of 5 secs and then second string
how can i acheive this?
i mean label should show first
label.text("before")
then it should wait for 5 secs and then it should show
label.text("After")


label.text = "before"
system.threading.thread.sleep(5000)
label.text = "after"

Note that the app is locked during the 5 sec. If you don't want this, you
can use a Timer (see System.Windows.Forms.Timer) instead. After setting the
label the first time, enable the timer (interval = 5000). In the Timer's
Tick event, disable the timer and set the label text again.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

P: n/a
Cor
Hi Amit,

Have a look at timer,
there are 3 can use the most simple for this the forms.form.timer

Although if you do not mind that your form freze you can also do
Roughly written here in this message
\\\
dim a as string() = {"Before","Middle","After"}
for i as integer = 0 to a.lenght - 1
label1.text = a(i)
threading.thread.sleep(5000)
next
///
I hope this helps

Cor

I want to know how can we insert delay in vb.net
like.....
i want to show two strings on same label
first one string then break of 5 secs and then second string
how can i acheive this?
i mean label should show first
label.text("before")
then it should wait for 5 secs and then it should show
label.text("After")

Nov 20 '05 #3

P: n/a
Cor
Hi Armin,

I think I get comments from Armin with my solution,

"Why not using a timer?

are you making the same

:-)

Cor
Nov 20 '05 #4

P: n/a
* "Cor" <no*@non.com> scripsit:
Have a look at timer,
there are 3 can use the most simple for this the forms.form.timer

Although if you do not mind that your form freze you can also do
Roughly written here in this message


You can make a loop looping from 1 to 5 and let the thread sleep for 1
second, then call 'Application.DoEvents'. Quick and dirty, I know.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

P: n/a
Cor
Hi Herfried,

That is my own solution in past often told not to be good by you

:-) again the whole day gone?

Cor
Have a look at timer,
there are 3 can use the most simple for this the forms.form.timer

Although if you do not mind that your form freze you can also do
Roughly written here in this message


You can make a loop looping from 1 to 5 and let the thread sleep for 1
second, then call 'Application.DoEvents'. Quick and dirty, I know.

Nov 20 '05 #6

P: n/a
* "Cor" <no*@non.com> scripsit:
That is my own solution in past often told not to be good by you

:-) again the whole day gone?


A lot of work for university.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #7

P: n/a
>
A lot of work for university.

Well I know I missed you. :)
Nov 20 '05 #8

P: n/a
Hi Amrin can't we have more genearl one that can show about 100 strings on a
specified gap

Thanks
Amit
"Armin Zingler" <az*******@freenet.de> wrote in message
news:O8**************@TK2MSFTNGP09.phx.gbl...
"AmitTrehan" <am************@hotmail.com> schrieb
hi friends,
I want to know how can we insert delay in vb.net
like.....
i want to show two strings on same label
first one string then break of 5 secs and then second string
how can i acheive this?
i mean label should show first
label.text("before")
then it should wait for 5 secs and then it should show
label.text("After")
label.text = "before"
system.threading.thread.sleep(5000)
label.text = "after"

Note that the app is locked during the 5 sec. If you don't want this, you
can use a Timer (see System.Windows.Forms.Timer) instead. After setting

the label the first time, enable the timer (interval = 5000). In the Timer's
Tick event, disable the timer and set the label text again.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #9

P: n/a
"AmitTrehan" <am************@hotmail.com> schrieb
Hi Amrin can't we have more genearl one that can show about 100
strings on a specified gap


At class level, store the information on what string to show next. In the
Timer's Tick event:
1. Use the information to show the string.
2. Change the information (an Index in a string array? Depends on your
needs) in order to show the right string next time. For example, increment
the index.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #10

P: n/a
* "scorpion53061" <Its the end of the world as we know it@here.com> scripsit:
A lot of work for university.


Well I know I missed you. :)


I missed the group and the people here too.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.