vb.net - How to use native Stopwatch with fewer decimal places? -
in visual basic 2010, how use built-in stopwatch function less accuracy/with fewer decimal places. building stopwatch. works well, has low framerate (about 5-10 fps) because stopwatch generates 10 decimal places! here's code lessen number of decimal places:
private sub timer1_tick(sender system.object, e system.eventargs) handles timer1.tick rounded = convert.todecimal(stopwatch1.elapsed) rounded2 = decimal.round(rounded, 2) label1.text = convert.tostring(rounded2) end sub
any help?
thanks!
i think best options use custom format elapsed value (which timespan) this:
private sub timer1_tick(sender system.object, e system.eventargs) handles timer1.tick label1.text = stopwatch1.elapsed.tostring("dd\.hh\:mm\:ss\.fff") end sub
where fff
optional number of milliseconds require - specify more or less f
's want.
note won't round value in case of stopwatch wouldn't want round anyway.
Comments
Post a Comment