+ Reply to Thread
Results 1 to 3 of 3

Generate a unique time stamp per x instruction cycles? Is it possible?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Generate a unique time stamp per x instruction cycles? Is it possible?

    I have been looking into some more challenging topics and this came up. Basically, I need a way to create a unique time stamp after a far smaller value than a second which seems to be Excels smallest unit. Any help is appreciated here.

    Public Function TimeInUS() As String
         Dim x As Integer
         For x = 1 To 10
              Range("B" & x).Value = x & "_person."
              Range("A" & x).Value = z     'TIME STAMP HERE <-------------
         Next x
    End Function

    Where 'z' is a new value slightly greater than itself a few microseconds ago. I need a value based off the time since I may run this program today, export the information, and re-run the program tomorrow with new data. The timestamp is a way to keep track of entered values througout all time.

    Maybe over kill doing it this way but any help is appreciated. Thank you.
    Last edited by 111StepsAhead; 04-03-2012 at 09:14 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Generate a unique time stamp per x instruction cycles? Is it possible?

    Have a look at the GetTickCount function (Windows API).

  3. #3
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: Generate a unique time stamp per x instruction cycles? Is it possible?

    I don't know if there is any way to get the times closer but what I have here will be ok. Thank you Chippy.

    Public Declare Function GetTickCount Lib "kernel32.dll" () As Long
    
    Sub testTimer()
        Dim t As Long
        Dim x As Long
        Dim temp As Long
        Dim temp2 As Long
        
        temp2 = 0
        For x = 1 To 50
            temp = temp2
            Do
                temp2 = GetTickCount
            Loop While temp = temp2
            Range("A" & x).Value = temp2
        Next x
    
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1