?
Solved

this seems weird

Posted on 2003-11-22
4
Medium Priority
?
178 Views
Last Modified: 2010-05-01
i was wondering if anyone could explain to me
why this code doesn't work?

it seems to ignore the date 01/01/2000

but it will stop when i told it to stop on
a certain day in 2005

thanks

code:

Private Sub Command1_Click()
Dim x As Date
Dim z As Date

x = Text1
z = Text2

For i = x To z
Label1 = i
If Label1 = "12/31/1999" Then MsgBox "end of 1999"
If Label1 = "01/01/2000" Then MsgBox "begin of 2000"
Next i
End Sub

Private Sub Timer1_Timer()
Command1_Click
End Sub


0
Comment
Question by:RunToTheHills
  • 3
4 Comments
 
LVL 13

Expert Comment

by:Glen A.
ID: 9805195
Most likely your long date format doesn't fit what you've got in your labels.

Ie:  if your date format on your pc is YYYY-MM-DD and you put "12/31/1998" in text1 your label1 is going to be "1998-12-31"

So your commands work fine because label1 will NEVER be "12/31/1999" no matter what.
0
 
LVL 13

Accepted Solution

by:
Glen A. earned 300 total points
ID: 9805199
change your for/next code as follows and it should work:

For i = x To z
   Label1 = Format(i, "MM-DD-YYYY")
   If Label1 = "12-31-1999" Then MsgBox "end of 1999"
   If Label1 = "01-01-2000" Then MsgBox "begin of 2000"
Next i
0
 

Author Comment

by:RunToTheHills
ID: 9805238
thanks

how can i change my pc's time format?

in the control panel date/time utility,
i don't see any options to change it to mm-dd-yyyy

i use ME

thanks again
0
 
LVL 13

Expert Comment

by:Glen A.
ID: 9805251
dunno about Me, but on my XP box it's in control panel, regional options.  Yours should be something similar.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question