Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools


If you're working with VB built-in date/time functions, you can use VB Format function to convert Date/Time to any format you need. But API functions often return time in milliseconds. See how to convert it in readable format:

Click here to copy the following block
Private Declare Function StrFromTimeInterval Lib "shlwapi" Alias "StrFromTimeIntervalA" (ByVal pszOut As String, ByVal cchMax As Long, ByVal dwTimeMS As Long, ByVal dwDigits As Long) As Long

'One of API functions which return time in milliseconds
Private Declare Function GetTickCount Lib "kernel32" () As Long

'Function to format time value. lTime is time in milliseconds,
'  lDigits show formatting range
'2 - hours
'4 - hours & minutes
'6 - hours, minutes & seconds
Private Function GetFormattedTime(ByVal lTime As Long, Optional lDigits As Long = 4) As String
  Dim StrOut As String
  StrOut = Space(64)
  Call StrFromTimeInterval(StrOut, Len(StrOut) - 1, lTime, lDigits)
  GetFormattedTime = Trim(StrOut)
End Function

Private Sub Form_Load()
  MsgBox "Your computer works " & GetFormattedTime(GetTickCount, 6)
End Sub


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.