Solved

this seems weird

Posted on 2003-11-22
4
161 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:AlbertaBeef
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:
AlbertaBeef earned 75 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:AlbertaBeef
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now