471,092 Members | 1,566 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,092 software developers and data experts.

using delay in vb.net

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
10 91859
"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
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
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
* "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
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
* "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
>
A lot of work for university.

Well I know I missed you. :)
Nov 20 '05 #8
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
"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
* "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.

Similar topics

14 posts views Thread by Des L. Davis | last post: by
11 posts views Thread by Maheshkumar.R | last post: by
reply views Thread by mookie | last post: by
14 posts views Thread by Steve Teeples | last post: by
2 posts views Thread by WhatHappend | last post: by
8 posts views Thread by Craig Williamson | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.