Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Vb.net] Question about a Timer.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
I'm C.H.
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Dec 2006
Posts: 1000
Location: Sweden

PostPosted: Sat Dec 20, 2008 10:39 am    Post subject: [Vb.net] Question about a Timer. Reply with quote

Well, I am making a timer that counts Hours, Seconds and Minutes. I've done everything so far but I need to know this one thing:

The Stop timer button stops the counting but when you start it again, the timers are back to default value. How can I make so that the timers only get paused?
Thx!

_________________
Omg. I need something to do...

*-* My Flash Trainers *-*

*-* My Mouse Vac Tut *-*

Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sat Dec 20, 2008 2:12 pm    Post subject: Reply with quote

I don't get exactly what the problem is here, how are you losing count? You can also try stopping a timer by simply setting the Enabled property to false.


You may find this easier to do with the DateTime and TimeSpan structures

Just find the difference by subtracting.
Back to top
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Sun Dec 21, 2008 3:12 am    Post subject: Reply with quote

use global variables, so they keep their values, show you code if you want me to show ya what i mean
_________________
Back to top
View user's profile Send private message
yoyonerd
Grandmaster Cheater
Reputation: 0

Joined: 26 Apr 2008
Posts: 699
Location: -->formerly yoyonerd<--

PostPosted: Sun Dec 21, 2008 3:18 am    Post subject: Reply with quote

are you using the timer control? or there's one in c# so im sure in vb.net that the stopwatch class exists as well

like snootae, post ur code, so we know whats wrong

_________________
Back to top
View user's profile Send private message AIM Address
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Sun Dec 21, 2008 4:26 am    Post subject: Reply with quote

hes using a timer control, but i dont recall that there was a resume / suspend function, but if its just counting, no point in using local vairables
_________________
Back to top
View user's profile Send private message
I'm C.H.
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Dec 2006
Posts: 1000
Location: Sweden

PostPosted: Sun Dec 21, 2008 9:30 am    Post subject: Reply with quote

Code:
Public Class Form1
    Dim Secs As Integer
    Dim Mins As Integer

    Private Sub Seconds_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Seconds.Tick
        Secs = Secs + 1
        Label3.Text = "Seconds: " & Secs

        If Int(Label1.Text / 60) = Label1.Text / 60 Then Label2.Text = Label2.Text + 1
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Seconds.Start()
    End Sub

    Private Sub Minutes_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Minutes.Tick
        Mins = Mins + 1
        Label2.Text = "Minutes: " & Mins
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Seconds.Enabled = False
        Minutes.Enabled = False
        Hours.Enabled = False
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Seconds.Enabled = False
        Minutes.Enabled = False
        Hours.Enabled = False
        Label1.Text = "Hours: 0"
        Label2.Text = "Minutes: 0"
        Label3.Text = "Seconds: 0"
        Seconds.Start()
        Minutes.Start()
        Hours.Start()
    End Sub
End Class

_________________
Omg. I need something to do...

*-* My Flash Trainers *-*

*-* My Mouse Vac Tut *-*

Back to top
View user's profile Send private message
Kerelmans
Advanced Cheater
Reputation: 0

Joined: 29 Oct 2007
Posts: 57

PostPosted: Mon Dec 22, 2008 2:57 pm    Post subject: Reply with quote

How about storing the time when the user starts, then make a timer tick every sec:

yourtime = $time - oldtime

(to lazy to actually make it xD)

should work...
Back to top
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Mon Dec 22, 2008 8:22 pm    Post subject: Reply with quote

Code:
Public Class Form1
    Dim secs, mins, hours As Integer

    Private Sub Time_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Seconds.Tick
        secs = secs + 1
        Label3.Text = "Seconds: " & secs
        If secs = 60 Then
            mins += 1
            secs = 0
            Label3.Text = "Minutes: " & mins
            If mins = 60 Then
                hours += 1
                mins = 0
                Label1.Text = "Hous: " & hours
            End If
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Time.enabled = True
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Time.enabled = False
    End Sub


eliminates the need for multiple timers, and keeps time

i dont know exatly what the point fo you button3 is, if it just resets it then
Code:
secs = 0
mins = 0
hours = 0

_________________
Back to top
View user's profile Send private message
yoyonerd
Grandmaster Cheater
Reputation: 0

Joined: 26 Apr 2008
Posts: 699
Location: -->formerly yoyonerd<--

PostPosted: Mon Dec 22, 2008 10:21 pm    Post subject: Reply with quote

is it a countdown timer, or a count up timer
_________________
Back to top
View user's profile Send private message AIM Address
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Mon Dec 22, 2008 10:27 pm    Post subject: Reply with quote

Code:
Secs = Secs + 1

id say up

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites