Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 30th, 2012, 11:54 PM
Authorized User
 
Join Date: Jan 2012
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default vba 2007 time difference and automatic update

WARNING: New to VBA please be very detailed.
I need a solution to a several of problems that I am having creating this userform in vba in excel 2007. I have a label1 that displays test time. A textbox for the user to enter Production time and a label2 that would be used to display the difference between times.
What I would like to do is ask the user for a production time and the test time will be equal to the current time. Once they enter in information I would like the time difference to be displayed in label2. But the method below used doesn't work. Also is there a way to display time difference automatically. Once they enter in production time it displays the time difference immediately no clicking on buttons. Here's what I have so far.Thanks.
Code:
Private Sub UserForm_Initialize()
 
Dim StartTime As String
Dim StopTime As String
Dim ElapseTime As Double

StopTime = LblTestTime2
StartTime = txtProductionTime
ElapseTime = (StopTime - StartTime) / 60
'ElapseTime.Caption = Format(ElapseTime, "hh:mm")

'Sets Test Time
 LblTestTime2.Caption = Format(Time, "hh:mm")
 
End Sub
 
Old December 9th, 2012, 09:29 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Please try using DateDiff function; You will have a better control with this

Regards
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
automatic time table generation thava PHP How-To 0 January 19th, 2010 03:29 AM
Difference btw. Access 2000, 2003, 2007 marcusalan Access ASP 0 May 26th, 2007 02:41 AM
Automatic Update odezzie Classic ASP Databases 1 March 28th, 2007 06:06 PM
Automatic Web Login using VBA raj_phoenix Excel VBA 0 April 25th, 2006 04:19 AM
Automatic Database Update notification bhaveshce Classic ASP Databases 1 April 3rd, 2004 07:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.