Results 1 to 4 of 4

Thread: DTPicker Query

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2005
    Posts
    100

    DTPicker Query

    Hi

    I am in the middle of a Biorhythm VB program and am wondering how to use Date Picker

    Currently I am working on a phase of 18 days, so I assume MOD18 will come into it somewhere (you can tell I am a beginner)

    My Date Picker seems to go back to Jan 1st 1601

    On that day, the 18 day cycle is on day 16 of the 18 day cycle.

    So what I need to know is - if I use Date Picker to choose a date of, say, March 9th 1967 - how can I get it to calculate what day of the 18 day cycle March 9th 1967 falls on (still assuming that Jan 1st 1601 is day 16 of the 18 day cycle)

    1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,0,1,2...........

    AND is there a site which simply explains how to use DP ?

    Thanks for looking

    Mike

  2. #2
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457

    Re: DTPicker Query

    Every date may be represented as a long using

    VB Code:
    1. Dim n as long
    2. n = Clng(Yourdate)

    Once you determine a frig factor to align to your 18 day sequence (call it FF) you can use the MOD to give you what you want. So....

    VB Code:
    1. Dim FF as Long, Remainder as Long
    2. n = Clng(Yourdate) - FF
    3. Remainder = n MOD 18

    .
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  3. #3
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Re: DTPicker Query

    The DTP is a simple control to use (IMO). The only properties I ever modify are the Format (3-dtpCustom), CustomFormat (M/dd/yyy), MinDate (the earliest date you want to allow the user to enter) and MaxDate (the latest date you want to allow the user to enter).

    The MinDate and MaxDate should accomodate the range of valid date values for a VB Date datatype: 1/1/100 thru 12/31/9999.

    The custom format is the "weird" thing about the control because the way you specify what you want is different from the normal specification of a date format, and it is case sensitive (for example, the equivalent of the date format "m/dd/yyyy" is "M/dd/yyy" for the DTP). Check out the MSDN help file on the DTP for the custom formatting.

    At run-time, simply check the Value property of the DTP control to see what the user has entered.

    I am attaching a sample app that does what you are looking for. It uses 2 DTPs, one for the origin date, the other for the cycle date to be tested. The crux of the code is:
    VB Code:
    1. Private Sub cmdCalc_Click()
    2.    
    3.     Dim lngDaysDiff As Long
    4.     Dim lngCycleDay As Long
    5.    
    6.     lngDaysDiff = DateDiff("d", dtpOriginDate.Value, dtpCycleDate.Value)
    7.     lngCycleDay = (lngDaysDiff Mod 18) + 1  ' I believe we need the + 1 here
    8.    
    9.     lblResult.Caption = Format$(dtpCycleDate.Value, "m/d/yyyy") _
    10.                       & " falls on day " _
    11.                       & lngCycleDay _
    12.                       & " of the 18-day cycle."
    13.    
    14.    
    15. End Sub
    I hope this helps.
    Attached Files Attached Files
    "It's cold gin time again ..."

    Check out my website here.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Apr 2005
    Posts
    100

    Re: DTPicker Query

    Thanks for both these examples

    I will try and incorporate this into the routine and see what happens

    Cheers

    Mike

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