Consulting

Results 1 to 7 of 7

Thread: Date format in userform text box

  1. #1
    VBAX Expert
    Joined
    Jan 2005
    Posts
    574
    Location

    Date format in userform text box

    can anyone tell me how to format my text box so my users can view a date in uk style and not us style?

    Also need to save the date from a text box into a spreadsheet in the correct format so will also need to change the format prior to the save

    cheers

    gibbo

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by gibbo1715
    can anyone tell me how to format my text box so my users can view a date in uk style and not us style?

    Also need to save the date from a text box into a spreadsheet in the correct format so will also need to change the format prior to the save

    cheers

    gibbo
    You can have any format in a textbox, doesn't have to be US style, so I don't get the first question.

    Second, cast it
    CDate(Textbox1.Text)
    ____________________________________________
    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

  3. #3
    VBAX Expert
    Joined
    Jan 2005
    Posts
    574
    Location
    sorry for my poor explanation, i have data on my spreadsheet that is formatted to uk style, when i call that data into my form (frm1.Textbox1.value = ActiveCell.Value) it is displayed as US Style i.e. in my cell 01/08/2005 where as on my userform it shows as 08/01/2005

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by gibbo1715
    sorry for my poor explanation, i have data on my spreadsheet that is formatted to uk style, when i call that data into my form (frm1.Textbox1.value = ActiveCell.Value) it is displayed as US Style i.e. in my cell 01/08/2005 where as on my userform it shows as 08/01/2005
    Okay, so just force it

    Textbox1.Text = Format(Range("A1").Value, "dd/mm/yyyy")
    .
    ____________________________________________
    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

  5. #5
    VBAX Expert
    Joined
    Jan 2005
    Posts
    574
    Location
    That worked great for displaying the data in a text box so my text box now displays dd/mm/yyyy as required, but doesnt work for saving the data to the spreadsheet

    How do I code the value in the text box so that when i save it i get dd/mm/yyyy format on my spreadsheet and not mm/dd/yyyy ?

    dont quite understand the CDate(Textbox1.Text)command can u explain this for me

    cheers

    gibbo?

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by gibbo1715
    How do I code the value in the text box so that when i save it i get dd/mm/yyyy format on my spreadsheet and not mm/dd/yyyy ?

    dont quite understand the CDate(Textbox1.Text)command can u explain this for me
    Range("B1").Value = CDate(TextBox1.Text)
    .
    ____________________________________________
    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

  7. #7
    VBAX Expert
    Joined
    Jan 2005
    Posts
    574
    Location
    Thanks for taking the time to explain that to me, certainly something i will be using in the future

    thankyou

    Gibbo

Posting Permissions

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