473,386 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Timer Question

I have a Yellow text box on a winform that normally stays hidden but on
occasion I make it visible to display some message to the user. In one
particular case it would be nice if the text box would only stay visible for
a few seconds. Is this possible? If so I suppose it involves a Timer
control but it is not clear to me how to program the Winform so that the
textbox stays visible only for a given period of time. If is is visible for
say only two seconds, would all other processing have to stop for two
seconds too?

Nov 20 '05 #1
4 1261
Hi,
Here is a simple-minded example that turns a textbox visible, and not
visible, using a timer, at 2-second intervals. You should be able to modify
it to do what you really want with no trouble. Just add a TextBox and Timer
to a Windows Forms project to give it a try.

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick

Static Visible As Boolean

TextBox1.Visible = Not (Visible)

Visible = TextBox1.Visible

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

With Timer1

Timer1.Interval = 2000

Timer1.Enabled = True

End With

End Sub

End Class
--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
Nov 20 '05 #2
* "Woody Splawn" <wo***@splawns.com> scripsit:
I have a Yellow text box on a winform that normally stays hidden but on
occasion I make it visible to display some message to the user. In one
particular case it would be nice if the text box would only stay visible for
a few seconds. Is this possible? If so I suppose it involves a Timer
control but it is not clear to me how to program the Winform so that the
textbox stays visible only for a given period of time. If is is visible for
say only two seconds, would all other processing have to stop for two
seconds too?


No, the Windows Forms Timer control doesn't block the execution.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

Hi Woody,

The timer will raise Tick event after an internal(you can specify), so you
can handle certain operations in this event handler.
And it will not block the execute of other controls.

For you issue, you can do like this:
'First, you should have placed a timer control on to the form.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
TextBox1.Visible = False
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Timer1.Interval = 2000
Timer1.Start()
TextBox1.Visible = True
End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Timer1.Stop()
TextBox1.Visible = False
End Sub

Hope this helps,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Woody Splawn" <wo***@splawns.com>
| Subject: Timer Question
| Date: Mon, 20 Oct 2003 11:20:23 -0700
| Lines: 13
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#i**************@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: 168.158-60-66-fuji-dsl.static.surewest.net
66.60.158.168
| Path:
cpmsftngxa06.phx.gbl!cpmsftngxa09.phx.gbl!TK2MSFTN GP08.phx.gbl!TK2MSFTNGP12.
phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:148442
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| I have a Yellow text box on a winform that normally stays hidden but on
| occasion I make it visible to display some message to the user. In one
| particular case it would be nice if the text box would only stay visible
for
| a few seconds. Is this possible? If so I suppose it involves a Timer
| control but it is not clear to me how to program the Winform so that the
| textbox stays visible only for a given period of time. If is is visible
for
| say only two seconds, would all other processing have to stop for two
| seconds too?
|
|
|
|
|
|

Nov 20 '05 #4
Thank you.

This worked
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: brian | last post by:
I have an ASP.Net application that uses impersonation. This works fine for accessing/executing the application. However, the app utilizes a timer, that when fired uses the <machine>ASPNET...
5
by: Richard P | last post by:
I need some help on timers. My app is asp.net 1.1 website running in a shared hosting environment with a third-party service provider. I currently request and cache 20 - 40 remote RSS feeds. When a...
6
by: Steve Jorgensen | last post by:
I know quite well that this question falls into the category of "why does Access misbehave when I do unexpected things to its objects?", but I thought I'd ask anyway, and see if anyone knows. ...
1
by: Paul Tomlinson | last post by:
Question about a System.Threading.Timer object and the "state" object you pass to it... Timer stateTimer = new Timer( = new TimerCallback( OnTimer ), o, 1000, 1000); I have an array of timer...
10
by: Bob | last post by:
Okay, I've done this for years but now I'm going to question it just because this idea has been at the back of my head since I started using DotNet... My WinForms app queries a database every 60...
7
by: RobKinney1 | last post by:
Hello, Wow...I have one for you all and hopefully I am not understanding this timer object correctly. I have a timer setup that pulses a connection through a socket every 60 seconds. But it...
12
by: Gina_Marano | last post by:
I have created an array of timers (1-n). At first I just created windows form timers but I read that system timers are better for background work. The timers will just be monitoring different...
11
by: Hotrod2000 | last post by:
I'm quite new to programming but I'm having problems getting a timer to work in visual studio.net I've created a timer on a form, enabled it and then typed the following code (from the mdsn...
16
by: Peter Oliphant | last post by:
Note that although this involves SAPI, it is more a question about Timers and event handlers. I wrote a Speech Recognize handler (SAPI), and put some code in it to enable a Timer. It would not...
11
by: Anil Gupte/iCinema.com | last post by:
When I use this Dim instance As New Timer I get the error: Error 1 Overload resolution failed because no accessible 'New' accepts this number of arguments. Yet, in the help section for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.