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
Solved

Show Running Time In VB.NET MDI Status Bar

Posted on 2011-03-07
5
966 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
  • 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 85

Accepted Solution

by:
Mike Tomlinson earned 250 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

828 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