Solved

Show Running Time In VB.NET MDI Status Bar

Posted on 2011-03-07
5
947 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 74

Expert Comment

by:käµfm³d 👽
Comment Utility
>>  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
Comment Utility

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
Comment Utility
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
Comment Utility
Hi Savant

Thank you. It works beautifully.
0
 

Author Closing Comment

by:Nolanc
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem with SqlConnection 5 108
Vb.Net Menu 1 21
How to change a specific bit from a file 2 19
Unable  to create new object 9 19
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now