.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Network >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Retrieves The Uptime of the Computer

Posted By:Hefin Dsouza       Posted Date: August 14, 2009    Points: 10    Category: Network    URL: http://www.dotnetspark.com  
 

This code sample is used to get the up time of a computer in .Net.

This Simple Code Written in VB.net to get the total time from when the computer is switched on



Module Module1

Public Function getUptime() As String
Dim time As String = String.Empty
time += Math.Round(Environment.TickCount / 86400000) & " days, "
time += Math.Round(Environment.TickCount / 3600000 Mod 24) & " hours, "
time += Math.Round(Environment.TickCount / 120000 Mod 60) & " minutes, "
time += Math.Round(Environment.TickCount / 1000 Mod 60) & " seconds."
Return time
End Function

Sub Main()
Console.WriteLine(getUptime())
End Sub

End Module
Regards
Hefin Dsouza

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend