vb.net - Time Span not working properly -


i'm working on download eta calculator..so use timespan code tell eta..the timespan code in visual basic not working should be... because when ever type file size , speed i.e 1gb , 1 mb/s, time span label1.text 5.17:00:00. here code

public class form1  private property z object  private sub linklabel1_linkclicked(sender object, e linklabellinkclickedeventargs) handles linklabel1.linkclicked     process.start("www.speedtest.net") end sub  private sub button1_click(sender object, e eventargs) handles button1.click     dim x, y, z, a, b, c single      x = textbox1.text     y = textbox2.text      if radiobutton1.checked = true , radiobutton3.checked = true         label4.text = "minutes"         z = x * 1024         c = y / 8         = z / c         label1.text = new timespan(a / 60, 0, 0).tostring()     end if      if radiobutton1.checked = true , radiobutton4.checked = true         label4.text = "minutes"         z = x * 1024         c = 1024 / 8 / y         = z / c         label1.text = new timespan(a / 60, 0, 0).tostring()     end if     if radiobutton2.checked = true , radiobutton3.checked = true         label4.text = "hours"         z = x * 1048576         c = y / 8         = z / c         b = / 60         label1.text = new timespan(a / 60, 0, 0).tostring()     end if     if radiobutton2.checked = true , radiobutton4.checked = true         label4.text = "hours"         z = x * 1048576         c = 1024 / 8 * y         = z / c         b = / 60         label1.text = new timespan(a / 60, 0, 0).tostring()     end if end sub  private sub radiobutton1_checkedchanged(sender object, e eventargs) handles radiobutton1.checkedchanged  end sub  private sub button2_click_1(sender object, e eventargs) handles button2.click     msgbox("made sldcvr enterprises", msgboxstyle.okonly, "about")  end sub 

end class

here designer

http://i.stack.imgur.com/f3pfm.jpg

timespan working correctly implementation wrong.

first fault: a/60 return integer instead of double. second fault: new timespan(h,m,s,ms) expects integers

the reason code compiles because compiler rounding on a/60 if change a/60 a/60d (d decimal) correct division compiler error. due integer limitation.

to fix error make division total number of seconds , (new timespan()).addseconds(your number);


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -