Re: Userform Date Formatting MM/DD/YYYY

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

anonymous_at_discussions.microsoft.com
Date: 01/05/05


Date: Tue, 4 Jan 2005 16:42:28 -0800

Bob -

Sure I'd appreciate it very much if you would give me
some code for those spin buttons.

Are you sure there isn't some way I could get that
software date mask to work? Also I found a third
alternative. I could create a calendar button in VB and
get the user to select the date from that. You probably
already know how to do this but if you want the code for
the calendar button from me I'll be more than happy to
post it. Thanks again,

Mike

>-----Original Message-----
>Mike,
>
>One way to this would be to have spinbuttons and 4
textboxes all linked. It
>requires more code, but it is more resilient.
>
>Do you want some code for it?
>
>--
>
>HTH
>
>RP
>(remove nothere from the email address if mailing direct)
>
>
>"Mike" <anonymous@discussions.microsoft.com> wrote in
message
>news:0ffd01c4f2aa$524a7530$a501280a@phx.gbl...
>> I just double checked and my textbox is definitely
named
>> TextBox2. I think one alternative would be to have
them
>> input the month in one list box, the day in another
list
>> box, and the year into a third list box. I could then
>> concantenate the output all into one cell. However
this
>> would require three seperate list boxes and to me that
>> seems cumbersome.
>>
>> >-----Original Message-----
>> >Are you sure that your textbox is named Texbox2 as in
the
>> code sample?
>> >
>> >It is very difficult to create a software date mask
>> (which is what you
>> >want), due to the number of combinations. The best
thing
>> is to trap the
>> >input, as my routine does, and then validate at the
end
>> that it is a valid
>> >date.
>> >
>> >--
>> >
>> >HTH
>> >
>> >RP
>> >(remove nothere from the email address if mailing
direct)
>> >
>> >
>> >"Mike" <anonymous@discussions.microsoft.com> wrote in
>> message
>> >news:052f01c4f291$2efbcc50$a601280a@phx.gbl...
>> >> Thank you in advance for your help.
>> >>
>> >> I have a UserForm with the following code:
>> >>
>> >> ActiveCell.Offset(0, 1).Select
>> >> Selection.NumberFormat = "MM/DD/YYYY"
>> >> ActiveCell = UserForm1.TextBox2
>> >>
>> >> The user is entering a date into TextBox2. I want
to
>> make
>> >> it so that they can only enter the date in
MM/DD/YYYY
>> >> format. The above code doesn't realy work.
>> >>
>> >> So far I have tried the following:
>> >>
>> >> 1. I went into Control Panel -> Regional Options
and set
>> >> the short date format as MM/DD/YYYY. This updates
the
>> >> dates when I type them directly into Excel but not
when
>> I
>> >> enter dates in the UserForm and then have the
UserForm
>> >> place the dates on the work***.
>> >>
>> >> 2. I also tried the following code from another
>> Newsgroup:
>> >> Private Sub TextBox2_KeyPress(ByVal KeyAscii As _
>> >> MSForms.ReturnInteger)
>> >> Dim cDelim As Long
>> >> cDelim = Len(TextBox2.Text) - Len(Replace
>> >> (TextBox2.Text, "/", ""))
>> >> Select Case KeyAscii
>> >> Case Asc("0") To Asc("9"): 'OK
>> >> Case Asc("/"):
>> >> If cDelim = 2 Then
>> >> KeyAscii = 0
>> >> Else
>> >> cDelim = cDelim + 1
>> >> End If
>> >> Case Else: KeyAscii = 0
>> >> End Select
>> >> End Sub
>> >>
>> >> This hasn't solved my problem either. Maybe I'm not
>> >> placing this code in the correct part of the
Userform?
>> I
>> >> am using Windows 2000 Professional and Excel 2000.
>> Thanks
>> >> again for your help.
>> >
>> >
>> >.
>> >
>
>
>.
>


Quantcast