PDA

View Full Version : Formatting TextBox



Juba
05-19-2009, 04:29 AM
Hello
can i Format TextBox to Appear with date Format
to show the user
/ /
and don't accept any kind of data Just date

Juba
05-19-2009, 04:40 AM
http://www2.0zz0.com/2009/05/19/11/690928094.gif
this Picture Declare what i mean

Bob Phillips
05-19-2009, 04:50 AM
This is incredibly convoluted, you have to parse what has been input previously, chcek what is entered, handle a delete, handle a backspace and so on. Far simpler to have three dropdowns in my view where they choose a year,. a month and a day.

Juba
05-19-2009, 05:15 AM
i see that xld
thanx for your suggestion
but can i make just the date inter in my textbox
i mean when any one try to write normal number excel refused it

Bob Phillips
05-19-2009, 05:25 AM
You could check it on AfterUpdate as



Private Sub TextBox1_AfterUpdate()
With Me.TextBox1

If Not IsDate(.Text) Then

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

Juba
05-19-2009, 05:55 AM
can i ask u xld, please
what we mean by
.SelStart = 0
.SelLength = Len(.Text)

Bob Phillips
05-19-2009, 07:46 AM
What that does it to reselect all of the text from character one, this is when it errors so that the users attention is drawn to the bad data.