Solved

this seems weird

Posted on 2003-11-22
4
166 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…

808 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