Thunder & Lightning

alfcen

Well-Known Member
Licensed User
Hi Erel,
This code excerpt runs fine on the desktop, however, on the device the number shown ( d ) when you press stop is always a multiple of 331 or a second. I observed this since Ver 5.8

B4X:
Sub buttLightStart_Click
  'Hint: Press as you see the lightning
  lightning = Now  'REM: lightning is global
End Sub

Sub buttLightStop_Click
  'Hint: Press as you hear the thunder
  Dim d
  d= (Now - lightning) / cTicksPerSecond * 331
  imgButtResult.Text = "Distance: " & d & " meters, " & Round(d * 3.281) & " feet"
End Sub
 
Last edited:

Erel

Administrator
Staff member
Licensed User
The Now property on the device is increased each second (by the OS).
You can't use it to measure milliseconds.
 

alfcen

Well-Known Member
Licensed User
Erel, I worked around with Dimitris' dzHW.dll.
Recommendation for the hardware library: hardware.GetTickCount
Cheers
 
Top