Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
format textbox to time | Excel Discussion (Misc queries) | |||
Format a Userform textbox to Military time | Excel Programming | |||
Format As TIME In A TextBox | Excel Programming | |||
TextBox in UserForm with 24h time format | Excel Programming | |||
textbox validation | Excel Programming |