Login    Register
User Information
Username:
Password:
We are a free and open
community, all are welcome.
Click here to Register
Sponsored
Who is online

In total there are 63 users online :: 6 registered, 0 hidden and 57 guests


Most users ever online was 155 on Mon Aug 15, 2016 1:40 am

Registered users: Bing [Bot], csitas, Google [Bot], Google Adsense [Bot], MSNbot Media, Yahoo [Bot] based on users active over the past 5 minutes

The Team
Administrators
Global Moderators
global_moderators.png CS

VB6 Month Timer Help

All non-spudgun related discussion goes here such as projects, theories, serious questions, etc. All "off-topic" posts (aka useless posting, determined by moderators) will be removed.
Sponsored 
  • Author
    Message

VB6 Month Timer Help

Unread postAuthor: john bunsenburner » 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!
  • 0

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
john bunsenburner
Major General
Major General
 
Posts: 1446
Joined: Sun Oct 19, 2008 5:13 am
Reputation: 0

Unread postAuthor: jrrdw » 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.
  • 0

When life gives you lemons...throw them back they suck!
User avatar
jrrdw
Donating Moderator
Donating Moderator
 
Posts: 6538
Joined: Wed Nov 16, 2005 5:11 pm
Location: Maryland
Country: United States (us)
Reputation: 25

Unread postAuthor: jimmy101 » 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.)
  • 0

Image

jimmy101
Lieutenant General
Lieutenant General
 
Posts: 3127
Joined: Wed Mar 28, 2007 9:48 am
Location: Greenwood, Indiana
Country: United States (us)
Reputation: 7

Unread postAuthor: john bunsenburner » 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...
  • 0

"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
john bunsenburner
Major General
Major General
 
Posts: 1446
Joined: Sun Oct 19, 2008 5:13 am
Reputation: 0

Unread postAuthor: TurboSuper » 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.
  • 0

"If at first you dont succeed, then skydiving is not for you" - Darwin Awards

TurboSuper
Brigadier General
Brigadier General
 
Posts: 986
Joined: Thu Jun 16, 2005 1:44 pm
Reputation: 0

Return to Non-Spudgun Related Discussion

Who is online

Registered users: Bing [Bot], csitas, Google [Bot], Google Adsense [Bot], MSNbot Media, Yahoo [Bot]

Reputation System ©'