User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 427,770 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,767 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 2394 | Replies: 2
Reply
Join Date: May 2007
Posts: 1
Reputation: Knight_Blazer is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Knight_Blazer Knight_Blazer is offline Offline
Newbie Poster

Help Creating a time counter

  #1  
May 3rd, 2007
I am try to create a couter that will show seconds and minutes. I need the counter to start at 0 seconds and 0 minutes. I made a label to display the the counter and named it Label1. I also have the timer object called Timer1. I think I might have got the timer to count but it did show up in the label. I told the timer to display in Label1 and made sure that Label1 was visible but it still doesn't work.

Below is my code that I've entered. If someone could please help me, it would be greatly appresiated. I really need this to work.

PublicClass Form1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim counter As Decimal
counter = 0.0
If Label1.Text = "" Then
Timer1.Enabled = True
Do
counter = counter + 1
Loop While counter > 0
Label1.Text = counter
Else
Label1.Text = "Done"
End If
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
Label1.Visible = True
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 1000
Label1.Text = ""
End Sub
End
Class
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2006
Location: East Amherst, NY
Posts: 102
Reputation: cutepinkbunnies is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 6
cutepinkbunnies's Avatar
cutepinkbunnies cutepinkbunnies is offline Offline
Junior Poster

Re: Creating a time counter

  #2  
May 3rd, 2007
Hi Knight_Blazer,


Do you have a stopwatch available? I'm a .net and greater guy, so lack experience with 6.0, but think the stopwatch control would be a bit better for you.

Let me know and I'll help you fix your code when I get home.

Jon
Reply With Quote  
Join Date: Apr 2007
Posts: 41
Reputation: vbCNEW is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 3
vbCNEW vbCNEW is offline Offline
Light Poster

Re: Creating a time counter

  #3  
May 3rd, 2007
hi.. first ithink its not right to put a loop insidde a counter because the timer is already like a loop thats why theres an interval declare for it to work .. i saw that you put 1000 in interval, so i guess u mean every minute it should trigger... so inside the timer just put sothing like this..

label1.caption = now - starttime

declare starttime as "public long" then give a value into it in form load or in the trigger of your timer if theres one..

i hope you get the idea..
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum

All times are GMT -4. The time now is 1:18 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC