LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default date entry in userform textbox

Thank you Joel,code a bit too long.using Cdate can you make it?

Joel wrote:
It is much easier to wrok with Textboxes when using Dates because they are
text strings and not a serial date which can change with regional settings.
Try this code

StrDate = Textbox1.text
'get the 1 or 2 digits before 1st slash and convert to number
DayNum = Val(StrDate,Instr(StrDate,"/")-1)
'get the string after the 1st slash
StrDate = mid(StrDate,Instr(StrDate)+1)
'get the month number before the slash and convert to number
MonthNum = Val(StrDate,Instr(StrDate,"/")-1)

'get the year after the slash
YearNum = val(mid(StrDate,Instr(StrDate)+1))
'add 2000 to year number
YearNum = YearNum + 2000
'convert date to serial format
SerDate=dateserial(YearNum,MonthNum,DayNum)
'Print the Date in required format
Textbox1.text = format(SerDate,"dd-mmm-yy")

Hello,VBA experts
how to validate date entries in TextBoxes (on Userform),user wants to enter
date values in dd/mm/yy format,entry is must in textbox,after entry and
exiting from textbox the textbox
entry be displayed in dd-mmm-yy format.(without changing computer's Regional
and language settings).


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200806/1

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Format for Userform TextBox John Calder New Users to Excel 4 July 29th 09 10:19 PM
Date Format in UserForm textbox. [email protected] Excel Programming 0 July 6th 07 03:52 PM
Copying TextBox entry from one UserForm to another excelnut1954 Excel Programming 6 January 23rd 06 07:12 PM
Ensuring UserForm Textbox Entry is numeric [email protected] Excel Programming 3 October 8th 04 11:20 PM
Date Calculation in UserForm TextBox John Pierce Excel Programming 2 February 28th 04 12:11 AM


All times are GMT +1. The time now is 04:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"