Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default TextBox Validation - Time Format


Hello Zani,

Since you are using multiple User Forms, the best approach is to use a
macro in a module that can be shared. Place this code in a VBA module
and call it from your code as in the example.

Calling the Macro:
CheckTimeEntry Textbox1

Just replace Textbox1 with the name of the TextBox whose entry you want
to check. If you want to check a TextBox on another User Form, the User
Form doesn't need to be visible, but must be loaded in memory and you
need to use the Form name when calling the macro.

Checking a TextBox on another Form:
CheckTimeEntry UserForm2.TextBox1
_______________________________

Public Sub CheckTimeEntry(ByRef Text_Box As MSForms.TextBox)

Dim MyTime As Date

On Error GoTo InvalidEntry
MyDate = CDate(Text_Box.Text)

Exit Sub

InvalidEntry:
MsgBox "The time value you entered is not valid."
Text_Box.Text = ""

End Sub
_______________________________

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=508912

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
format textbox to time ASU Excel Discussion (Misc queries) 3 June 7th 06 10:05 PM
Format a Userform textbox to Military time Christy Excel Programming 2 August 24th 05 10:15 PM
Format As TIME In A TextBox Minitman[_4_] Excel Programming 4 February 9th 05 12:55 AM
TextBox in UserForm with 24h time format Mika Excel Programming 1 February 1st 05 07:45 PM
textbox validation Beginner[_2_] Excel Programming 1 April 7th 04 07:46 PM


All times are GMT +1. The time now is 12:22 PM.

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"