[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

this seems weird

Posted on 2003-11-22
4
Medium Priority
?
176 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Suggested Courses

656 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