Consulting

Results 1 to 3 of 3

Thread: Solved: Non American date format in textbox

  1. #1
    VBAX Regular
    Joined
    Sep 2011
    Posts
    78
    Location

    Solved: Non American date format in textbox

    Hi,

    I am displaying dates from a spreadsheet in textboxes on a form. I prefer to use a date format that is known and commonly used in my counry, South Africa, i.e. yyyy/mm/dd.

    My local settings are like that and the dates display correctly in a cell. However, when the cell is linked using controlsource or object.value = cell.value to a textbox on a form, the date is displayed in the American date format mm/dd/yyyy.

    I know I can circumvent it by using something like object.value = year(cdate(range).value)) & "/" & month(cdate(range).value)) & "/" & day(cdate(range).value)), but would prefer to do it in a simpler way, if possible.

    All help would be appreciated.

    Regards

    Zagrijs
    Last edited by zagrijs; 12-04-2012 at 06:56 AM.

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    Instead of using 'rowsource' you'd better use .List (in a listbox or combobox):

    [vba]
    ListBox1.List = Application.Transpose(Application.Transpose(Sheets(1).Cells(1).CurrentRegio n.Value))

    [/vba]

    In a textbox :

    [vba]
    Textbox1.text=format(sheets(1).cells(1).value,"yyyy-mm-dd")
    [/vba]

    or

    [VBA]
    TextBox1.Text = FormatDateTime(Cells(1, 3).Value, vbGeneralDate)

    [/VBA]

  3. #3
    VBAX Regular
    Joined
    Sep 2011
    Posts
    78
    Location
    Thanks. Problem solved

Posting Permissions

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