Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

> vb.net timer, Timer functions

views
     
TSWalaweiii
post Apr 10 2019, 04:31 PM, updated 7 months ago

New Member
*
Newbie
22 posts

Joined: Jan 2019


need some help
im using vs 2019 and i know the default count for timer in vs is 1000 miliseconds which is 1 seconds.

how do i change the code if let say:
i take input from user in seconds, and i change it to ms.
where do i replace the miliseconds value?

i mean..the timer has no code right?
KanGz
post Apr 10 2019, 04:37 PM

Getting Started
**
Junior Member
95 posts

Joined: Apr 2011
From: Selangor


timer.Interval = 1000;
cytyler
post Apr 10 2019, 04:37 PM

Getting Started
**
Junior Member
176 posts

Joined: Nov 2014
timer has no default count
just convert s to ms (x1000)
eg.
Timer1.Interval = 1000; //ms
hoilok
post Apr 10 2019, 04:37 PM

Regular
******
Senior Member
1,130 posts

Joined: Apr 2007




update the timer property
TSWalaweiii
post Apr 10 2019, 04:44 PM

New Member
*
Newbie
22 posts

Joined: Jan 2019


QUOTE(KanGz @ Apr 10 2019, 04:37 PM)
timer.Interval = 1000;
*
yes i did that..but i want it to count as seconds
cytyler
post Apr 10 2019, 04:57 PM

Getting Started
**
Junior Member
176 posts

Joined: Nov 2014
QUOTE(Walaweiii @ Apr 10 2019, 04:44 PM)
yes i did that..but i want it to count as seconds
*
elaborate what u actually want to do ...its very brief with ur request
KanGz
post Apr 10 2019, 05:04 PM

Getting Started
**
Junior Member
95 posts

Joined: Apr 2011
From: Selangor


QUOTE(Walaweiii @ Apr 10 2019, 04:44 PM)
yes i did that..but i want it to count as seconds
*
#3 post already answer you

you received 3 seconds from user input, then convert to ms equal to 3000.

x.Interval = 3000;
x.Start();

thats all.
Eventless
post Apr 10 2019, 05:57 PM

Look at all my stars!!
*******
Senior Member
2,541 posts

Joined: Jan 2003
If an object requests a value to be in the form of millisecond, you provide the value in millisecond. If you don't like that option, your other option would be to create a new control based on timer that accepts the interval value in seconds.
kevinlim001
post Apr 11 2019, 09:35 AM

Ethical Hacker
*******
Senior Member
4,901 posts

Joined: May 2006
From: Planet called "EARTH"



you can create your own function if u wan insist on your second interval instead of milisecond interval

This post has been edited by kevinlim001: Apr 11 2019, 09:35 AM
CKKwan
post Apr 11 2019, 09:39 AM

Enthusiast
*****
Senior Member
866 posts

Joined: Dec 2004
User enter 3

3 x 1000 = 3000 ms = 3 s

TS failed kindergarten maths gah?
turnmoil
post Apr 11 2019, 10:47 AM

Casual
***
Junior Member
405 posts

Joined: Jan 2003
From: The Miau Miaw Niau Miow Land


just convert by some math calculations...
there is no direct method for it..

but not that hard also
Moshpit94
post Apr 11 2019, 02:41 PM

Getting Started
**
Junior Member
219 posts

Joined: Feb 2011
From: Earth
Just do conversion la...

CODE
Dim ts As TimeSpan = TimeSpan.FromMilliseconds(milliseconds)
MessageBox.Show(ts.Minutes.ToString & " minutes and " & ts.Seconds.ToString & " seconds")
MessageBox.Show("Total Minutes: " & ts.TotalMinutes.ToString)
MessageBox.Show("Total Seconds: " & ts.TotalSeconds.ToString)


lantaurus
post Jun 2 2019, 06:12 AM

New Member
*
Junior Member
28 posts

Joined: Dec 2015
From: Melaka


Try use timespan

https://docs.microsoft.com/en-us/dotnet/api...etframework-4.8
Alphaseti P
post Jun 2 2019, 09:56 PM

New Member
*
Probation
7 posts

Joined: May 2019
timer object is in miliseconds. Therefore, conversion to objecti (as in timer) would be x(seconds) X 1000 (constant to milliseconds) as per required by the object reference.

Eg:
' Timer1.Interval --> this is in ms
Timer1.Interval = 2000; ' 2 Seconds
Timer1.Start() '

 

Switch to:
| Lo-Fi Version
0.0333sec    4.54    5 queries    GZIP Disabled
Time is now: 15th October 2019 - 12:33 AM