CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 1999
    Location
    SC, USA
    Posts
    22

    How to best enter dates?

    I need to allow entry of 2 or 4 digit years, with or without /s. When 2 digit years are entered, I need to display back with 4 digits, then allow change.

    Would rather not use masked edit due to disimilar events exposed compared to other "standard" entry controls.


    John Kisner
    J.L.Kisner & Co., Inc.
    Greenville, SC, USA
    864-233-6941

  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: How to best enter dates?

    VB 6 comes with several controls that support date entries such as DTPicker, a combobox that allows you to enter a date as well as select one from a drop down dialog.
    There is also a MonthView control.

    Get access to these controls by creating a new VB project and choose "VB EnterPrise Controls".


  3. #3
    Join Date
    Aug 1999
    Location
    SC, USA
    Posts
    22

    Re: How to best enter dates?

    Thanks, Lothar.

    At your suggestion I tried out the DTPicker control and it looks like a very good one.

    Our general app specs require us to also use each control for entry of search parameters in our "FIND" mode. An example: "3/22/99..5/22/99" is used for entering a range of dates.

    To do this requires changing the max characters property and accepting characters invalid to date entry. I'm afraid we will have to write our own custom control, perhaps incorporating the DTPicker and a text box.

    Thanks again for the tip.


    John Kisner
    J.L.Kisner & Co., Inc.
    Greenville, SC, USA
    864-233-6941

  4. #4
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    Some idea...

    The DTPicker.Value property returns a string with the selected date by the user. You can then use the format() to take the desired format of the date e.g. "yyyy-mm-dd". So you can with such way to take only the digits you want: If for example you like the year to be with only 2 digits: "yy-mm-dd". I don't know if I helped you, let me know... I have used the dtpicker control on databases and I have also searched the db for a space of dates. If you have problem on that ask me...

    Michael Vlastos
    Automation Engineer
    Company Modus SA
    Development Department

  5. #5
    Join Date
    Aug 1999
    Location
    SC, USA
    Posts
    22

    Re: Some idea...

    Thanks very much for your helpful response. I see now that the flexibility of this control meets all of our entry needs for a single date.

    I want to also provide for the entry of a range of dates when the form is used for entry of parameters used in selecting a recordset. Exp: "6/1/99..7/31/99" for use in logic which selects a recordset containing all records with dates in that range.

    The only way I can see to do that is to overlay a text box when the form is used that way.

    John Kisner
    J.L.Kisner & Co., Inc.
    Greenville, SC, USA
    864-233-6941

  6. #6
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    Re: Some idea...

    I don't think you need a text box. If I understood well you must use something like this:
    SELECT * FROM TABLE WHERE FIELD1 >= cstr(DTPicker1.value) AND FIELD2 <= (DTPicker2.value)





    Michael Vlastos
    Automation Engineer
    Company Modus SA
    Development Department

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

Featured