Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Show Running Time In VB.NET MDI Status Bar

Posted on 2011-03-07
5
Medium Priority
?
1,037 Views
Last Modified: 2013-11-27
Hi

In my VB.NET MDI Windows Application I have a Status Bar with a panel named StbTime. I wish to show the correct time (All the time) in this panel. What is the easiest way of doing this please. For example StbTime.Text = TimeOfDay is useless.

I am using Visual Studio 2008 running under Windows XP Pro.

Many thanks.
0
Comment
Question by:Nolanc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35057542
>>  For example StbTime.Text = TimeOfDay is useless.

Well yes, in and of itself it is useless as I'm sure you found out, it will only update whenever the section of code you place that in is executed (e.g. a button being clicked). What you need is that code and a timer to fire that code at some defined interval (e.g. every second). Place that code inside of a Tick handler and start the timer when you're form loads--you should then have better results.
0
 

Author Comment

by:Nolanc
ID: 35058207

Hi kaufmed

I was hoping that you would provide me with some code to achieve this.  However, let me continue searching the Internet for code of this nature after which I will get back to you.

Thanks.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 1000 total points
ID: 35059040
You don't really need any code...just do it thru the IDE.

Add a Timer to your Form.  It's near the bottom of the ToolBox in the "Components" section.
Select the Timer (in the grey area below your form) and change the Interval Property in the Properties Pane (bottom right of the screen) to 1000.
Change the Enabled Property to True.
Now Double Click the Timer below your form to get the method stub in your code.
Add the code to display the time of day.

It should look something like this when you're done:
Public Class Form1

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        StbTime.Text = DateTime.Now.ToString("h:mm:ss tt")
    End Sub

End Class

Open in new window

0
 

Author Comment

by:Nolanc
ID: 35067997
Hi Savant

Thank you. It works beautifully.
0
 

Author Closing Comment

by:Nolanc
ID: 35068025
Hi Savant

I merely replaced your statement No. 4 with my statement as follows: StbTime.Text = TimeOfDay. It works perfectly.

Thanks
Nolan
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question