VB6 Month Timer Help

Meaningful discussion outside of the potato gun realm. Projects, theories, current events. Non-productive discussion will be locked.
User avatar
john bunsenburner
Sergeant 5
Sergeant 5
Posts: 1446
Joined: Sun Oct 19, 2008 5:13 am

Sun Aug 09, 2009 5:14 am

Well, this is pretty much as far from spud guns as can get, but still there are a few members on here that are very familiar with visual basic, and so, before I go out and search for a whole new forum, i assumed asking you guys for help would be a good idea, so here I go:

I have been designing a program, just for fun, part of it involves counting months, simply adding 1 to a label's caption every time a month passes. The problem is the fact months tend to vary in length, and because this should be fairly accurate(and no, leap years are no problem, I will deal with those my self) at any given time i have tried to code the program in a manner in which each month is treated separately, now without further ado, I'll just give you guys the code.

Code: Select all

Private Sub Form_Load()
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
Label1.Caption = (Label1.Caption + 1)
Lbl1.Caption = (Lbl1.Caption + 1)
If Label1.Caption = 60 Then
Label2.Caption = (Label2.Caption + 1)
Label1.Caption = 0
End If
If Label2.Caption = 60 Then
Label3.Caption = (Label3.Caption + 1)
Label2.Caption = 0
End If
If Label3.Caption = 24 Then
Label4.Caption = (Label4.Caption + 1)
Label3.Caption = 0
End If
If Lbl1.Caption = 604800 Then
Label5.Caption = (Label5.Caption + 1)
Lbl1.Caption = 0
End If
If Label4.Caption = 31 Then
Label6.Caption = (Label6.Caption + 1)
End If
If Label4.Caption = 59 Then
Label6.Caption = (Label6.Caption + 1)
End If
If Label4.Caption = 90 Then
Label6.Caption = (Label6.Caption + 1)
End If
If Label4.Caption = 120 Then
Label6.Caption = (Label6.Caption + 1)
End If
If Label4.Caption = 151 Then
Label6.Caption = (Label6.Caption + 1)
End If
If Label4.Caption = 181 Then
Label6.Caption = (Label6.Caption + 1)
End If
If Label4.Caption = 212 Then
Label6.Caption = (Label6.Caption + 1)
End If
If Label4.Caption = 243 Then
Label6.Caption = (Label6.Caption + 1)
End If
If Label4.Caption = 273 Then
Label6.Caption = (Label6.Caption + 1)
End If
If Label4.Caption = 304 Then
Label6.Caption = (Label6.Caption + 1)
End If
If Label4.Caption = 334 Then
Label6.Caption = (Label6.Caption + 1)
End If
If Label4.Caption = 365 Then
Label6.Caption = 0
Label4.Caption = 0
End If
End Sub
Label4 displays days
Label6 months

Thanks in advance for all your help! Happy spudding, and enjoy your summer, or winter!
Last edited by john bunsenburner on Sun Aug 09, 2009 3:25 pm, edited 1 time in total.
"Did you ever stop to think that out of the seven deadly sins envy is the only one which doesn't give the sinner even momentary pleasure"-George Will
User avatar
jrrdw
Moderator
Moderator
United States of America
Posts: 6569
Joined: Wed Nov 16, 2005 5:11 pm
Location: Maryland
Has thanked: 39 times
Been thanked: 22 times
Contact:

Donating Members

Sun Aug 09, 2009 7:14 am

Post this at Theopia in the computer section, "Turbosuper" is one of the most knowlagable members that I know of, he probly can help you with this.
jimmy101
Sergeant Major
Sergeant Major
United States of America
Posts: 3197
Joined: Wed Mar 28, 2007 9:48 am
Location: Greenwood, Indiana
Has thanked: 5 times
Been thanked: 15 times
Contact:

Sun Aug 09, 2009 11:39 am

You reset Label4.Caption = 0 twice in the program. Once at the end of Febuary and again at the end of the year. Is that what you intend? (Day and month counting like this is often done relative to the first of March instead of Jan 1, since that allows leap years to be treated by adding one day after the last day of the year; Feb. 28.)

"Label6.Caption ++" is much more readable than is "Label6.Caption = (Label6.Caption + 1) ". (Or "++Label6.Caption" or whatever VB's increment by one command is.)
Image
User avatar
john bunsenburner
Sergeant 5
Sergeant 5
Posts: 1446
Joined: Sun Oct 19, 2008 5:13 am

Sun Aug 09, 2009 3:32 pm

Ok ill post on theopia, i also forgot to mention the problem i get:

When the label4.caption=31 then the label6.caption starts goin up in seconds...
"Did you ever stop to think that out of the seven deadly sins envy is the only one which doesn't give the sinner even momentary pleasure"-George Will
TurboSuper
Corporal 5
Corporal 5
Posts: 986
Joined: Thu Jun 16, 2005 1:44 pm
Been thanked: 1 time

Sun Aug 09, 2009 8:25 pm

Yay, I'm knowledgeable :D

To be fair Zarno and Los Frijoles probably know more about this stuff than I do, I just get to the threads quicker.
"If at first you dont succeed, then skydiving is not for you" - Darwin Awards
Post Reply