Results 1 to 3 of 3

Thread: ATTN: VB PRO'S (Aaron Young, MartinLiss, Yonatan, and others) formatting a text box

  1. #1

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    What I need is some way of rearranging the format of a date in a text box. The problem is that the date is not always going to be in the same format, meaning that it would be in the one of the following formats

    • m/d/yy
    • m/dd/yy
    • mm/d/yy
    • mm/dd/yy


    and I need to change it into this format:

    yyyy-mm-dd

    maybe there's another way to do this besides what I'm thinking, but here's what I think I'm going to have to do. I'm thinking of how you do this using PERL, and I was wondering if there is some way to do something similar in VB. I need to find some way of searching the date string for the '/' that are always in the date string. And then from there I can rearrange the order and separate them by the '-'.

    ------------------
    Ryan


    [This message has been edited by Gimpster (edited 01-13-2000).]

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Just use the Format Function, ie.
    Code:
    Private Sub Command1_Click()
        Text1 = Format(Text1, "yyyy-mm-dd")
    End Sub
    It will take the Date in any of the Formats you described, and more, and put in the Format yyyy-mm-dd.

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]


  3. #3

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    Thank you so much! It works perfectly!

    ------------------
    Ryan

Posting Permissions

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



Click Here to Expand Forum to Full Width