+ Reply to Thread
Results 1 to 7 of 7

add 12:00 displays on userform in textbox change to 0:05 ?

  1. #1
    Registered User
    Join Date
    07-31-2016
    Location
    Oman
    MS-Off Ver
    2016
    Posts
    5

    Exclamation add 12:00 displays on userform in textbox change to 0:05 ?

    Hello,

    after add 12:00 displays on userform in textbox change to 0:05 ?
    please help me ,,,

    Please Login or Register  to view this content.
    Last edited by max-7; 08-01-2016 at 09:30 AM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: add 12:00 displays on userform in textbox change to 0:05 ?

    Hi, welcome to the forum

    why would you want 12 hours to show as 5 minutes?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    07-31-2016
    Location
    Oman
    MS-Off Ver
    2016
    Posts
    5

    Re: add 12:00 displays on userform in textbox change to 0:05 ?

    I need wirte 12:00 show same 12:00
    no need to change to 0:05
    this change come an automatic

  4. #4
    Registered User
    Join Date
    07-31-2016
    Location
    Oman
    MS-Off Ver
    2016
    Posts
    5

    Re: add 12:00 displays on userform in textbox change to 0:05 ?

    Is it possible to help me ,,,

  5. #5
    Registered User
    Join Date
    07-31-2016
    Location
    Oman
    MS-Off Ver
    2016
    Posts
    5

    Re: add 12:00 displays on userform in textbox change to 0:05 ?

    Is there a way to solve this problem?

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: add 12:00 displays on userform in textbox change to 0:05 ?

    Hi,

    12:00 is equal to half a day because Excel holds date/time values as the number of days from 1st January 1900 (or 1904 on a Macintosh).

    Thus your program flow is to load 0.5 into the textbox in the Initialize event. This is stored as text, hence "0.5". Unfortunately, Format("0.5", "hh:mm") is not the same as Format(0.5, "hh:mm"). The former returns 00:05 rather than the latter's 12:00 presumably interpreting the full stop as a delimiter between hours and minutes when coercing the string to a true time value.

    To avoid this you may simply format the cell value when you load it into the textbox.

    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  7. #7
    Registered User
    Join Date
    07-31-2016
    Location
    Oman
    MS-Off Ver
    2016
    Posts
    5

    Re: add 12:00 displays on userform in textbox change to 0:05 ?

    Quote Originally Posted by xlnitwit View Post
    Hi,

    12:00 is equal to half a day because Excel holds date/time values as the number of days from 1st January 1900 (or 1904 on a Macintosh).

    Thus your program flow is to load 0.5 into the textbox in the Initialize event. This is stored as text, hence "0.5". Unfortunately, Format("0.5", "hh:mm") is not the same as Format(0.5, "hh:mm"). The former returns 00:05 rather than the latter's 12:00 presumably interpreting the full stop as a delimiter between hours and minutes when coercing the string to a true time value.

    To avoid this you may simply format the cell value when you load it into the textbox.

    Please Login or Register  to view this content.
    Thank you so much,,,

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel VBA: Change the Color of the text in the Textbox Userform
    By himaruasuka in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-25-2016, 08:25 AM
  2. cant keep typing in userform textbox after change event
    By jed38 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-01-2014, 09:13 AM
  3. Quickly change multiple UserForm TextBox names
    By PDBartlett in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-11-2014, 08:51 AM
  4. UserForm TextBox occasionally displays tiny, unreadable text
    By yay_excel in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-08-2013, 05:07 PM
  5. Replies: 3
    Last Post: 05-07-2012, 09:46 PM
  6. Change Userform Textbox based on GUI Cell Selection
    By canyon289 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-09-2011, 06:21 PM
  7. Userform Textbox and Label change from cell
    By Panic in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-20-2008, 08:36 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1