LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Validating Textbox-Value

How about this? It seems to work for me.

Private Sub txtStartDate_Exit(ByVal Cancel As MSForms.ReturnBoolean)

On Error GoTo ErrThisSub

If Len(Me.txtStartDate) 0 Then
Me.txtStartDate = DateValue(FormatDateTime(Me.txtStartDate, vbShortDate))
End If

Exit Sub

ErrThisSub:
MsgBox "Unexpected error formatting Start Date entry." & vbCrLf & _
"Error: " & Err.Number & "-" & Err.Description
Me.txtStartDate.Value = ""
Cancel = True
Resume Next
End Sub

Where txtStartDate is the name of my textbox control on my form. The
FormatDateTime function takes just about any string that could be formatted
to a date and returns a valid date type. Even the strings 39931 becomes
4/27/2009.

John

"Ueli Werner" wrote:

Hi newsgroup

In my excel form I have a textbox where a date value can be entered. When I
enter a wrong value excel crashes.

Now I like to validate this entry with some kind of entry mask. I like to
verify that the entered value cannot be someting other than a date?

Is there a possibility to do this in excel?

Thanks alot

Ueli Werner



 
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
Validating a unique reference in a textbox Blondegirl[_10_] Excel Programming 4 May 18th 06 04:59 PM
Validating number of characters in textbox Blondegirl[_9_] Excel Programming 2 May 10th 06 01:57 PM
validating input of textbox before publishing eyesonly1965 Excel Programming 4 May 7th 06 03:18 PM
validating input in textbox Jean-Pierre D via OfficeKB.com Excel Programming 1 August 15th 05 08:37 PM
Validating Entry into Textbox Brad[_11_] Excel Programming 1 December 4th 03 02:58 PM


All times are GMT +1. The time now is 09:48 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"