Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default looping when checking isdate

I use a user form with text box that the user shall write a date in. after
pressing abutton the info in the textbox shall be investigated in order to
see that it is a date. if not then display messagebox if otherwise go back to
user form so that the user can insert new info. i just do not get how to do
the loop. how do you "go back" in the loop? vb just complains that it is
private? my code is:

Private Sub callMainProgramButton_Click()
strStartDatum = TextBox1.Text
Call checkDate
Call mainProgram
Unload Me
End Sub

Private Sub checkDate()
Worksheets("Setup").Range("a15") = strStartDatum
If (Not (IsDate(strStartDatum))) Then
MsgBox "Wrong format"
Cancel = True
End If
End Sub


As you can see the upper sub calls the lower sub in which isDate is checked.
however when the sub checkDate() has done one loop i want it to retun
"somewhere" and get new info from the text field. help!!! please!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default looping when checking isdate

why not just use the exit event of the Textbox

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
if not isdate(me.Textbox1.Text) then
msgbox "Invalid date, try again" & vbNewLine & _
"Use a format like 08/21/2006"
me.Textbox1.Text = ""
Cancel = True
end if
End Sub

--
Regards,
Tom Ogilvy

It would be less confusing to the user if the entry is validated right away.

--
Regards,
Tom Ogilvy


"april27" wrote:

I use a user form with text box that the user shall write a date in. after
pressing abutton the info in the textbox shall be investigated in order to
see that it is a date. if not then display messagebox if otherwise go back to
user form so that the user can insert new info. i just do not get how to do
the loop. how do you "go back" in the loop? vb just complains that it is
private? my code is:

Private Sub callMainProgramButton_Click()
strStartDatum = TextBox1.Text
Call checkDate
Call mainProgram
Unload Me
End Sub

Private Sub checkDate()
Worksheets("Setup").Range("a15") = strStartDatum
If (Not (IsDate(strStartDatum))) Then
MsgBox "Wrong format"
Cancel = True
End If
End Sub


As you can see the upper sub calls the lower sub in which isDate is checked.
however when the sub checkDate() has done one loop i want it to retun
"somewhere" and get new info from the text field. help!!! please!

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
Macro for Looping for Criteria Checking FARAZ QURESHI Excel Discussion (Misc queries) 5 June 22nd 07 03:19 AM
IsDate? Arne Hegefors Excel Worksheet Functions 3 January 30th 07 01:44 PM
IsDate april27 Excel Programming 9 June 16th 06 02:14 PM
VBA function , IsDate() not available Office Engineer Excel Programming 3 May 27th 05 07:19 AM
IsDate Function Don Lloyd Excel Programming 14 August 23rd 04 05:57 AM


All times are GMT +1. The time now is 08:39 PM.

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"