Search code examples
millisecondsvb5

Getting system time milliseconds


I am not a VB programmer, let alone a VB3 programmer on a Windows NT. Everything here is difficult and ackward.

All what I have to do is to get system milliseconds. So from hereI know that this might be possible.

I therefore added the line:

TimeValue=Gettickcount()

but that function is unknown. So I added (in another part of the code)

 Declare Function GetTickCount Lib "kernel32" () As Long

and that apparently works for it compiles. Except for the fact that at the runtime it says: Kernel32 not found

So I change and write Kernel32 .dll but now it doesn't find the dll I search the dll on the system, I find it (367kb in C:\WinNt\System32\ ) and copy where the .mak resides but now it shows an

Error in loading dll

Now I really don't know what else to do!

Please note that it is VB3 not VB5 as I wrote in the tag. There just wasn't a VB3 tag.


Solution

  • From https://www.freevbcode.com/ShowCode.asp?ID=6441 I get the solution for VB5-VB6.

    Well almost the solution for it shows 1/100 of seconds not really 1/1000 but that is nearly there.

    Public Function MyTime() As String
        MyTime = Format(Now, "dd-MMM-yyyy HH:nn:ss") & "." & Right(Format(Timer, "#0.00"), 2)
    End Function
    

    It should work also on VB3. Give it a try!