VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

 

Code Snippets

  

VB.NET Source Code


Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 340,103 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 4,748 people online right now. Registration is fast and FREE... Join Now!




Get how long the computer has been running.

Get a human readable string representation of the amount of time the computer has been on since the OS started.

Submitted By: RodgerB
Actions:
Rating:
Views: 1,590

Language: VB.NET

Last Modified: December 8, 2007
Instructions:
1) Copy and paste the function into a class.
2) Read on how to call the function.

Snippet


  1. ''' <summary>
  2. ''' Get a human readable string representation of the
  3. ''' amount of time the computer has been on since the OS started.
  4. ''' </summary>
  5. ''' <returns>How long the computer has been running in days, hours
  6. ''' minutes and seconds.
  7. ''' </returns>
  8. ''' <remarks></remarks>
  9.  
  10. Public Function getUptime() As String
  11.     Dim strResult As String = String.Empty
  12.     strResult += Math.Round(Environment.TickCount / 86400000) & " days, "
  13.     strResult += Math.Round(Environment.TickCount / 3600000 Mod 24) & " hours, "
  14.     strResult += Math.Round(Environment.TickCount / 120000 Mod 60) & " minutes, "
  15.     strResult += Math.Round(Environment.TickCount / 1000 Mod 60) & " seconds."
  16.     Return strResult
  17. End Function
  18.  
  19. ' Example usage of this function.
  20. MessageBox.Show(getUptime)

Copy & Paste


Comments

NickMich 2007-12-09 15:11:05

really cool function dude

carmelaacedera 2007-12-17 04:02:07

hay naku!!bkt ung gust0 k0ng isearch di k0 m search??....Hmp!!!

RodgerB 2007-12-19 22:50:10

:S

jagatworld 2008-05-19 00:43:23

great.......

VAISHNAV_RAJKUMAR 2009-07-06 08:21:37

GOOD


Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month