Welcome Guest ( Log In | Register )


Bump Topic Add Reply RSS Feed New Topic New Poll

Outline · [ Standard ] · Linear+

> vb.net timer, Timer functions

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

New Member
*
Group: Newbie
Posts: 22

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
**
Group: Junior Member
Posts: 92

Joined: Apr 2011
From: Selangor


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

Getting Started
**
Group: Junior Member
Posts: 152

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
******
Group: Senior Member
Posts: 1,124

Joined: Apr 2007



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

New Member
*
Group: Newbie
Posts: 22

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
**
Group: Junior Member
Posts: 152

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
**
Group: Junior Member
Posts: 92

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!!
*******
Group: Senior Member
Posts: 2,536

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
*******
Group: Senior Member
Posts: 4,763

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
*****
Group: Senior Member
Posts: 818

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
***
Group: Junior Member
Posts: 363

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
**
Group: Junior Member
Posts: 203

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)





Bump Topic Add ReplyOptions New Topic
 

Switch to:
| Lo-Fi Version
0.0750sec    2.82    5 queries    GZIP Disabled
Time is now: 24th May 2019 - 02:50 PM