Solved

Displaying System Time and Date

Posted on 1998-12-16
4
153 Views
Last Modified: 2010-05-03
I need to create a bar that will appear on the bottom of the screen that will display a user defined ID number, time of the system clock, time since a physiology program begins recording (the manufacturer will help me with this), and the date. I know QBasic but am new to Visual Basic 6.0.
I have created the input form and a form to display a bar. I am not sure how to display the clocks and date on the bar. Any advice would be appreciated.
0
Comment
Question by:zrick
  • 3
4 Comments
 

Accepted Solution

by:
JimmieToo earned 50 total points
ID: 1450827
Zrick:

I'm assuming you have a 'statusbar' on your form but this approach will work with anything that has the text property.  If it was a Label then of course you would use the caption property.

Set the timer (called "tmrShowTime") interval to say 250 to 500.
You could combine the date and time and show the whole works in the statusbar.  Here, I'm displaying the date as a tooltip, just as Win 95 does on the desktop.

Private Sub tmrShowTime_Timer()

    'update the time in the statusbar
    With StatusBar1.Panels(2)
        .Text = Format$(Time$, "h:mm:ss am/pm")
        .ToolTipText = Format$(Now, "Long Date")
    End With

End Sub

Now for the other information, add the required Panels to your status bar.  Then to display user ID number, for instance;

Assume Text1 is entry for ID.

In the change event:

Private Sub Text1_Change()

    StatusBar1.Panels(1).Text = "User ID: " & Text1.Text

End Sub

Finally, you have another timer which is enabled by an event trigger supplied by the manufacturer.  You save the starttime in a variable and compare it at a regular interval with the current time and calculate the elapsed time.  Display the result in a textbox, label, another statusbar panel or whatever.

Hope this does the trick.

Jim


0
 

Author Comment

by:zrick
ID: 1450828
JimmieToo, Thanks for your answer, I look forward to trying this out! Rick
0
 

Author Comment

by:zrick
ID: 1450829
JimmieToo,

I am having difficulty applying the above. I ran the vbasic wizard to create an application and this created a statusbar with three panels: "status", date, and time. If I right click on the statusbar I get a properties menu. I can't change the value in ToolTip or Text to show "User ID: "& Text1.Text as it shows just that, these words witht the quotes and everything. If I try to add the statements you wrote out to the code itself, the program does not recognize them. Newbie as I am, I know I am doing something wrong here. I'd appreciate a bit more help.
0
 

Author Comment

by:zrick
ID: 1450830
I got it now by using Labels instead of the StatusBar.
Rick
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

708 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

13 Experts available now in Live!

Get 1:1 Help Now