Solved

Displaying System Time and Date

Posted on 1998-12-16
4
157 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

809 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