Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 295
  • Last Modified:

Putting a clock into VB and liking to it

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
MattRawling
Asked:
MattRawling
1 Solution
 
JoaTexCommented:
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
 
JoaTexCommented:
ooops, Sorry Set Timer1.Interval= 1000
Jo
0
 
MattRawlingAuthor Commented:
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
Industry Leaders: 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!

 
JoaTexCommented:
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
 
MattRawlingAuthor Commented:
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
 
CleanupPingCommented:
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
 
DanRollinsCommented:
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now