Android Question milliseconds between time


Well-Known Member
Licensed User
i am trying to slow down clicking on some button

i thought of using date and time for that so each 600 milliseconds the user can click

i have tried to do the following by some threads in this forum

Sub btn1_Click
Dim sendtime As Long
Dim lastsendtime As Long

sendtime = DateTime.Now

Log(sendtime - lastsendtime)
'here i am trying to capture if the difference between two times is smaller than or equal 600 then return

lastsendtime = DateTime.Now

End Sub

but the log shows big numbers that i couldn't figure out how to convert them to actual milliseconds


Licensed User
When your are logging the time difference, as you have it, lastsendtime will always be zero. You need to declare lastsendtime outside the btn1_click sub (global)
Upvote 0

Peter Simpson

Licensed User
Longtime User
Not tested.

'Process Globals
    Private PressedAt As Long
    Private WaitTime As Long = 600 'Milliseconds

    Private Button1 As Button

    If PressedAt = 0 Or (DateTime.Now - PressedAt) >= WaitTime Then
        PressedAt = DateTime.Now
        Log($"Pressed at ${DateTime.Time(DateTime.Now)}"$)
        'Your code goes here
        Log($"Oops!!! pressed too soon  ${DateTime.Now - PressedAt}"$)
    End If

Upvote 0