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
B4X:
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
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)
'Process Globals
Private PressedAt As Long
Private WaitTime As Long = 600 'Milliseconds
'Globals
Private Button1 As Button
'Button1_Click
If PressedAt = 0 Or (DateTime.Now - PressedAt) >= WaitTime Then
PressedAt = DateTime.Now
Log($"Pressed at ${DateTime.Time(DateTime.Now)}"$)
'Your code goes here
Else
Log($"Oops!!! pressed too soon ${DateTime.Now - PressedAt}"$)
End If