?
Solved

this seems weird

Posted on 2003-11-22
4
Medium Priority
?
171 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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: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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

801 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