Results 1 to 3 of 3

Thread: System Date compared against a string

  1. #1
    ben101
    Guest

    Question System Date compared against a string

    Hi

    Back again! (great site - very helpful)

    Is it possible to compare the system date with a written date?
    I've shown the current date by:

    Label1.caption = date

    I've a list box which has several dates which the user clicks
    on to obtain information for that particular date. These dates I've displayed by just putting them in quotes i.e. "10th April 2001".

    Can I check these dates against the system date and disable the choice should the date have passed?

    Any help gratefully received

    TKS

    Ben

  2. #2
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    Gig Harbor, WA; Posts: 89950
    Posts
    360
    you could try this
    Code:
    Listbox_Change() 
    If listbox.text >= Date then 
    'Enter Code Here 
    End If
    Last edited by Lee M.; Apr 28th, 2001 at 03:49 PM.
    Mahalo
    VB6(SP5), VC++, COBOL, Basic, JAVA
    MBA, MCSD, MCSE, A+
    Computer Forensics

  3. #3
    Tygur
    Guest
    Actually, this is how it should be:
    Code:
    Listbox_Change()
    If CDate(listbox.text) >= Date then
    'Enter Code Here
    End If
    for example, if you type these two lines:
    MsgBox CDate("30 April 2001") < Date
    MsgBox "30 April 2001" < Date

    ...the first message box will say False and the second one will say True. (Assuming April 30, 2001 didn't come yet)

    Also, the way you're typing the date may have to be changed. If you type the date as "10th April 2001", the above code will give an error. If you type it as "10 April 2001", it'll be fine. (at least that's how it is on my computer)

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