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 October 9th, 2007, 02:17 PM
Authorized User
 
Join Date: Jan 2007
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Time format problem in userform

I have a userform in a workbook where i want the user setup a time interval with 2 comboboxes, one for starttime and one for stoptime. The comboboxes have a list with a range of time in the format h:mm:ss, eg. 13:48:30. The problem is that when the user select a time, it will automatically be converted to decimal format(eg.0.57)in the userform (The user see the selected time suddenly being converted to decimal format). How can i prevent that and keep the format h:mm:ss

 
Old October 10th, 2007, 08:34 AM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Try something like the code below in afterupdate of the textbox:
TextBox1.Value = Format(TextBox1.Value, "HH:MM:SS")

You'll probably want to initialize it in the form.activate:
TextBox1.Value = Format(Now, "HH:MM:SS")

NOTE: This doesn't do validation so invalid values, such as non-numeric characters, can still be entered into the textbox. I'd suggest checking the value and displaying a message if the data entered into the field is incorrect.






Similar Threads
Thread Thread Starter Forum Replies Last Post
date time format vb certified Pro VB 6 4 December 18th, 2009 08:16 AM
Time format MDM ASP.NET 2.0 Professional 2 July 12th, 2006 10:37 AM
stored procedure: time format/mismatch problem. MDM ASP.NET 2.0 Professional 1 April 12th, 2006 03:42 PM
Using xs:time to generate time in desired format krayan001 XSLT 0 June 27th, 2005 04:28 PM
Format Date Time ganesh15 PHP How-To 2 August 20th, 2003 05:26 AM





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