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 


Mousai's VB Help Thread
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Mousai
Expert Cheater
Reputation: 0

Joined: 24 Jul 2006
Posts: 119
Location: Irving, Texas

PostPosted: Wed Feb 27, 2008 12:43 pm    Post subject: Mousai's VB Help Thread Reply with quote

This is my 'help' thread I'll post here when I need help. >_>
I use VBS2008, Windows XP SP2.(Just to get that out of the way.)
Well my overall project is to make a Mushmom Timer, so I can use what I've learned so far. But I want to have the users current system time on the form as well. And I use:
Code:
lblSysTime.text = TimeString

in the form_load and it just displays the current time but doesn't keep counting.>_> I've used it before and I even went back to that chapter in my book and redid it. But it still does the same thing.
So yeah, can someone help me!? D:
Also, I was trying to think of a way to change the timer time to count down like minutes but I'm not sure how. I was thinking of displaying it in a certain format. But yeah>_> Any help would be appreciated. SO YOU BETTER HELP! >:O

_________________
Back to top
View user's profile Send private message
Blader
I post too much
Reputation: 2

Joined: 19 Jan 2007
Posts: 2049

PostPosted: Wed Feb 27, 2008 2:56 pm    Post subject: Reply with quote

Use a timer on 100 interval and keep updating the time ( every second ).
As for counting down, you could also use a timer, then if it's 00:00 then stop the timer.

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

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Feb 27, 2008 3:11 pm    Post subject: Reply with quote

http://msdn2.microsoft.com/en-us/library/ms724390(VS.85).aspx perhaps?
Back to top
View user's profile Send private message
Mousai
Expert Cheater
Reputation: 0

Joined: 24 Jul 2006
Posts: 119
Location: Irving, Texas

PostPosted: Wed Feb 27, 2008 7:56 pm    Post subject: Reply with quote

Blader wrote:
Use a timer on 100 interval and keep updating the time ( every second ).
As for counting down, you could also use a timer, then if it's 00:00 then stop the timer.


Awesome I got it to subtract 1.6666666666666667 from 4500 and used Int to round it up. Although I can't seem to think of a way to make it look like time. I tried putting this in with the Timer1_tick:

Code:
If eventTimer - 60 then
eventTimer = eventTimer - 160
End If


Of course those aren't the right numbers but you get the idea. So that it
makes it look like it counts down. But that didn't work lol.

But what I meant by the time thing is, I want it to show the users system time. Like, when
Code:
labelx.text = TimeString
it shows the time for that instance and doesn't update. Used to it would update. >_>

Quote:
http://msdn2.microsoft.com/en-us/library/ms724390(VS.85).aspx perhaps?

Lol I don't know how to use anything from MSDN.
A little help would be nice. :O

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

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Feb 27, 2008 8:37 pm    Post subject: Reply with quote

http://pinvoke.net/default.aspx/kernel32/GetSystemTime.html
Back to top
View user's profile Send private message
Blader
I post too much
Reputation: 2

Joined: 19 Jan 2007
Posts: 2049

PostPosted: Thu Feb 28, 2008 5:22 am    Post subject: Reply with quote

I made a quick example of count down in seconds (attached)
_________________
Back to top
View user's profile Send private message
Mousai
Expert Cheater
Reputation: 0

Joined: 24 Jul 2006
Posts: 119
Location: Irving, Texas

PostPosted: Thu Feb 28, 2008 10:46 am    Post subject: Reply with quote

:O I know how to do the count down, it's just making it look like it's 45minutes.(45:00 and going down 60 that's the hard part.>_>) I've attached my version of the count down, it should take 45minutes to get to 0 but starts at 4500 so it looks similar to a clock.

Quote:

http://pinvoke.net/default.aspx/kernel32/GetSystemTime.html

Lol>_>, well I don't see why my TimeString doesn't work. It used to before. =/

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

Joined: 02 Nov 2007
Posts: 1371

PostPosted: Thu Feb 28, 2008 12:15 pm    Post subject: Reply with quote

Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Enabled = True
    End Sub

    Private Sub timer1_tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If Label1.Text <> 0 Then
            Label1.Text = Label1.Text - 1
        End If
    End Sub

how hard can it be?

_________________
Intel over amd yes.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
Mousai
Expert Cheater
Reputation: 0

Joined: 24 Jul 2006
Posts: 119
Location: Irving, Texas

PostPosted: Thu Feb 28, 2008 2:50 pm    Post subject: Reply with quote

Naablet wrote:
Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Enabled = True
    End Sub

    Private Sub timer1_tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If Label1.Text <> 0 Then
            Label1.Text = Label1.Text - 1
        End If
    End Sub

how hard can it be?

Omgosh>___>
Ok look, I got that. But how is -1 every interval going to to do anything?
1 minute = 60 seconds riiigghhttt?
45 minutes = 2,700 seconds
Ok so I can't put 4500 and subtract 1 every time or else I'd end up with 75minutes!
So that's why I subtract 1.67 at every interval
because I can't make the next digit decrease after the other one has only gone down 6 like an actual clock. I tried something similar to that but it didn't work. I tested it and it's right on the dot(45mins). But I want something that counts down 45:00 like a stopwatch! Gosh.>_>
Although as I was typing that I got an idea a different timer for a different label, it turned out decent but I need to mess with it some more.

_________________
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Thu Feb 28, 2008 6:33 pm    Post subject: Reply with quote

Intervals are done as milliseconds in VB.

1 second = 1000 milliseconds
1 minute = 60 seconds = 60,000 milliseconds

You should get the point on that.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Mousai
Expert Cheater
Reputation: 0

Joined: 24 Jul 2006
Posts: 119
Location: Irving, Texas

PostPosted: Thu Feb 28, 2008 7:22 pm    Post subject: Reply with quote

Wiccaan wrote:
Intervals are done as milliseconds in VB.

1 second = 1000 milliseconds
1 minute = 60 seconds = 60,000 milliseconds

You should get the point on that.

Oh, my, god.
If we're counting down as a clock would. (New years)
Freaking it would go 200, 159, 100, 059. Right?
And - 1 every interval is like?
200 199 100 099 not 59...
I know that 1 second = 100 milliseconds and so on.
I've almost made my count down thing, but it uses different timers
and different labels. But I just need to adjust it a bit. Gosh>_>
Thanks for the help though.

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

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Thu Feb 28, 2008 7:32 pm    Post subject: Reply with quote

Mousai wrote:

I know that 1 second = 100 milliseconds and so on.


1 second is a 1000 milliseconds homie
Back to top
View user's profile Send private message
AoiMasamune
Master Cheater
Reputation: 1

Joined: 14 Jun 2007
Posts: 255

PostPosted: Thu Feb 28, 2008 8:12 pm    Post subject: Reply with quote

I see what you're trying to do.

I would do it this way:

Code:

Private iHours as Integer
Private iMinutes as Integer
Private iSeconds as Integer

Public Sub Countdown()
     iSeconds = iSeconds - 1
     If iSeconds < 0 Then
          iSeconds = 59
          iMinutes = iMinutes - 1
          If iMinutes < 0 Then
              iMinutes = 59
              iHours = iHours - 1
              If iHours < 0 Then
                   Call Countdown_Done
              End If
          End If
      End If
      Call Show_Countdown
End Sub

Public Sub Show_Countdown()
     Dim strTime as String
     Dim strTemp as String

     strTemp = iHours
     If strTemp.Length = 1 Then
          strTemp = "0" & strTemp
     End If
     strTime = strTemp

     strTemp = iMinutes
     If strTemp.Length = 1 Then
          strTemp = "0" & strTemp
     End If
     strTime = strTime & ":" & strTemp

     strTemp = iSeconds
     If strTemp.Length = 1 Then
          strTemp = "0" & strTemp
     End If
     strTime = strTime & ":" & strTemp

     Form1.lblTimeRemaining.Text = strTime
End Sub



Set the timer's delay to 1000 so it fires once a second, and put Call Countdown() in it's event.


EDIT: Added some length checking to Show_Countdown to make sure it looks like a clock.

That should give you the 'clock' look.
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Thu Feb 28, 2008 8:48 pm    Post subject: Reply with quote

._.

I woulda figured that he just wanted to show like MM:SS

Here's C# (sorry, I don't know the modulo command in VB)

[code]
void Timer_Tick(object sender, TimerEventArgs e)
{
string sLblText = String.Empty;
int iMins = 0, iSeconds = 0;

Timer timer = (Timer)sender;
iSeconds = timer.Time / 1000; //I forget what the property of the timer is, to access the time, but whatever

iMins = iSeconds / 60;
iSeconds = iSeconds % 60; //modulo, the remainder

sLblText = iMins.ToString() + ":" + iSeconds.ToString();
MyLabel.Text = sLblText;
}

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
Mousai
Expert Cheater
Reputation: 0

Joined: 24 Jul 2006
Posts: 119
Location: Irving, Texas

PostPosted: Thu Feb 28, 2008 10:34 pm    Post subject: Reply with quote

slovach wrote:
Mousai wrote:

I know that 1 second = 100 milliseconds and so on.


1 second is a 1000 milliseconds homie

Miss type?>_>

AoiMasamune wrote:

Code:
Private iHours as Integer
Private iMinutes as Integer
Private iSeconds as Integer

Public Sub Countdown()
     iSeconds = iSeconds - 1
     If iSeconds < 0 Then
          iSeconds = 59
          iMinutes = iMinutes - 1
          If iMinutes < 0 Then
              iMinutes = 59
              iHours = iHours - 1
              If iHours < 0 Then
                   [b]Call Countdown_Done[/b]
              End If
          End If
      End If
      Call Show_Countdown
End Sub

Public Sub Show_Countdown()
     Dim strTime as String
     Dim strTemp as String

     strTemp = iHours
     If strTemp.Length = 1 Then
          strTemp = "0" & strTemp
     End If
     strTime = strTemp

     strTemp = iMinutes
     If strTemp.Length = 1 Then
          strTemp = "0" & strTemp
     End If
     strTime = strTime & ":" & strTemp

     strTemp = iSeconds
     If strTemp.Length = 1 Then
          strTemp = "0" & strTemp
     End If
     strTime = strTime & ":" & strTemp

     Form1.lblTimeRemaining.Text = strTime
End Sub

That's pretty much what I done but a little differently.
Why is call Countdown_Done there?
I don't know why the hell I didn't think of concatenation's when I was doing it but, wouldn't I need do:
Code:
If strTemp.Length = 1 Then
          strTemp = "0" & strTemp
     End If

for 1-9 and not just 1. All n' all thanks for the code, I'm gonna try it out and tweak it a little.

@Samuri25404
Heh yours is a little different
But I don't understand how yours works though. My minutes = my seconds \ 60? it started to seem to make sense then it kinda went away haha. I'll examine it more closely later. >_>

_________________
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
Goto page 1, 2  Next
Page 1 of 2

 
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