?
Solved

Show Running Time In VB.NET MDI Status Bar

Posted on 2011-03-07
5
Medium Priority
?
1,015 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

741 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