Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 275
Default Userform input question

Hi,

Is there a way to 'force' a user to input the time on my userform in the
format xx:xx, ie 24hrs with ':' between the hours and minutes
for example......

12:23 is good
09:12 is good
8:15 is good
1223 is bad
0912 is bad
815 is bad

the txtbox for this on the userform are txttime and txtATA

if the wrong format is used I would ideally like a msgbox to appear to
advise wrong format used.

hope you can help
thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Userform input question

I don't think so.

You could validate the input after their done, though.

Or maybe you could use two controls (one for the hours and one for the minutes).

Or even a time picker.
http://www.dailydoseofexcel.com/arch...3/time-picker/

Anthony wrote:

Hi,

Is there a way to 'force' a user to input the time on my userform in the
format xx:xx, ie 24hrs with ':' between the hours and minutes
for example......

12:23 is good
09:12 is good
8:15 is good
1223 is bad
0912 is bad
815 is bad

the txtbox for this on the userform are txttime and txtATA

if the wrong format is used I would ideally like a msgbox to appear to
advise wrong format used.

hope you can help
thanks


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Userform input question

Hi,

Try this

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Me.TextBox1.Value = Format(Me.TextBox1.Value, "hh:mm")
End Sub

Mike

"Anthony" wrote:

Hi,

Is there a way to 'force' a user to input the time on my userform in the
format xx:xx, ie 24hrs with ':' between the hours and minutes
for example......

12:23 is good
09:12 is good
8:15 is good
1223 is bad
0912 is bad
815 is bad

the txtbox for this on the userform are txttime and txtATA

if the wrong format is used I would ideally like a msgbox to appear to
advise wrong format used.

hope you can help
thanks


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Userform input question

Why not just put the colon in for them? If your TextBox is named TextBox1,
then this will take the assign the time value either way it is entered...

TheTimeValue = Format(Replace(TextBox1.Value, ":", ""), "00:00")

More important, I would think, is to make sure there are only numbers and
one colon maximum inputted. Something like this maybe...

If Len(TBvalue) - Len(Replace(TBvalue, ":", "")) 1 Then
MsgBox "You have too many colons!"
ElseIf Not TBvalue Like "*:##" Then
MsgBox "You do not enough digits after the colon!"
Else
TBvalue = Replace(TBvalue, ":", "")
If TBvalue Like "*[!0-9]*" Then
MsgBox "Enter digits and one colon only!"
ElseIf Len(TBvalue) 4 Then
MsgBox "You have too many digits!"
Else
TheTimeValue = Format(Replace(TBvalue, ":", ""), "00:00")
End If
End If



Rick


"Anthony" wrote in message
...
Hi,

Is there a way to 'force' a user to input the time on my userform in the
format xx:xx, ie 24hrs with ':' between the hours and minutes
for example......

12:23 is good
09:12 is good
8:15 is good
1223 is bad
0912 is bad
815 is bad

the txtbox for this on the userform are txttime and txtATA

if the wrong format is used I would ideally like a msgbox to appear to
advise wrong format used.

hope you can help
thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Userform input question

You could validate the input after they're done, though.
(grammar police)

Dave Peterson wrote:

I don't think so.

You could validate the input after their done, though.

Or maybe you could use two controls (one for the hours and one for the minutes).

Or even a time picker.
http://www.dailydoseofexcel.com/arch...3/time-picker/

Anthony wrote:

Hi,

Is there a way to 'force' a user to input the time on my userform in the
format xx:xx, ie 24hrs with ':' between the hours and minutes
for example......

12:23 is good
09:12 is good
8:15 is good
1223 is bad
0912 is bad
815 is bad

the txtbox for this on the userform are txttime and txtATA

if the wrong format is used I would ideally like a msgbox to appear to
advise wrong format used.

hope you can help
thanks


--

Dave Peterson


--

Dave Peterson
Reply
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
UserForm, with no input pgarcia Excel Discussion (Misc queries) 0 September 14th 07 05:02 PM
Check Input, into Input box question Les Stout[_2_] Excel Programming 2 June 21st 07 06:37 PM
Formatiing a input Box in a Userform Jeff Excel Discussion (Misc queries) 0 April 13th 06 08:57 PM
Input$ Userform luk_sr[_2_] Excel Programming 0 January 3rd 06 09:27 PM
Userform Input Into Excel Kris Taylor Excel Programming 5 January 19th 05 06:02 PM


All times are GMT +1. The time now is 09:33 AM.

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

About Us

"It's about Microsoft Excel"