View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
TUNGANA KURMA RAJU TUNGANA KURMA RAJU is offline
external usenet poster
 
Posts: 171
Default textbox validation with 3 conditions

Mr.Bob,Your code hasn't given me desired results.I entered a date value in
TextBox1, 04/06/08(what I mean 4thJune2008),it converted to 06-Apr-08.I want
result 04-Jun-08.

"Bob Phillips" wrote:

I would use the AfterUpdate event and just check that it is a date, let them
enter it however they want, and reform at it


Private Sub TextBox1_AfterUpdate()
With Me.TextBox1

If IsDate(.Text) Then

.Text = Format(CDate(.Text), "dd-mmm-yy")
Else

MsgBox "Invalid date entry"
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End If
End With
End Sub

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"tkraju via OfficeKB.com" <u16627@uwe wrote in message
news:855a96bfe9e31@uwe...
thank you Bob.Working fine !
one more question.
how to validate date entries in TextBoxes (on Userform),user wants to
enter
date values in dd/mm/yy form,after entry and exiting from textbox the
textbox
entry be displayed in dd-mmm-yy format.

Bob Phillips wrote:
With Me.TextBox2

If .Text < "" And _
(Not IsNumeric(.Text) Or _
Val(.Text) Me.TextBox1.Text) Then

MsgBox "Invalid value"
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
Exit Sub
End If

'OTHER CODE
End With

Mr.Rick Rothstein gave me correct vb code for testing two textbox for
(equal)values.
[quoted text clipped - 15 lines]
or
corrects the entry by putting exact values as in TextBox1.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200806/1