Consulting

Results 1 to 7 of 7

Thread: Formatting TextBox

  1. #1

    Formatting TextBox

    Hello
    can i Format TextBox to Appear with date Format
    to show the user
    / /
    and don't accept any kind of data Just date

  2. #2

    this Picture Declare what i mean

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    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

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You could check it on AfterUpdate as

    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    can i ask u xld, please
    what we mean by
    [VBA] .SelStart = 0
    .SelLength = Len(.Text)
    [/VBA]

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •