?
Solved

Putting a clock into VB and liking to it

Posted on 2003-03-11
8
Medium Priority
?
291 Views
Last Modified: 2010-04-07
I need to put a clock into my VB program. I then need to be able to at the press of a command button enter the time into a desired text box.

Cheers for any help you are able to provide

Matt
0
Comment
Question by:MattRawling
[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
8 Comments
 
LVL 2

Expert Comment

by:JoaTex
ID: 8116161
Hi

Put in a Form:

1 Timer
1 CommonButton
1 TextBox
1 Label

Put This Code:


Option Explicit
Dim myTime

Private Sub Command1_Click()
   Text1.Text = Label1.Caption
End Sub

Private Sub Form_Load()
   Timer1.Enabled = True
   Label1.Caption = Time
End Sub

Private Sub Timer1_Timer()
   myTime = Time
Label1.Caption = myTime
End Sub

Run It
Jo
0
 
LVL 2

Expert Comment

by:JoaTex
ID: 8116169
ooops, Sorry Set Timer1.Interval= 1000
Jo
0
 

Author Comment

by:MattRawling
ID: 8116287
Cheers Jo that helps a lot. Just one little thing. How can i find the difference in hours miuntes and seconds between two text boxes which i have entered the time into?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Accepted Solution

by:
JoaTex earned 500 total points
ID: 8116432
Hi

Ok. Put another textbox,Commonbutton and label in your form and put the code:

Option Explicit
Dim myTime
Dim endTime
Dim StartTime
Dim DifTime
Private Sub Command1_Click()
   Text1.Text = ""
   Text2.Text = ""
   Label2 = ""
   Text1.Text = Label1.Caption
   StartTime = myTime
End Sub
Private Sub Command2_Click()
   endTime = Time
   Text2.Text = endTime
   DifTime = endTime - StartTime
   Label2 = Format(DifTime, "hh:mm:ss")
End Sub
Private Sub Form_Load()
   Timer1.Enabled = True
   Label1.Caption = Time
End Sub

Private Sub Timer1_Timer()
   myTime = Time
   Label1.Caption = myTime
End Sub

Jo
0
 

Author Comment

by:MattRawling
ID: 8116523
Cheers Jo. Very kind of you. You have greatly improved the chances of me passing my final year dissitation and me actually getting a degree!

Matt
0
 

Expert Comment

by:CleanupPing
ID: 9056421
MattRawling:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 9097165
Moderator, my recommended disposition is:

    Accept JoaTex's comment(s) as an answer.
    *** The dissitation is a sertinty now!

DanRollins -- EE database cleanup volunteer
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 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