Thunder & Lightning

Discussion in 'Questions (Windows Mobile)' started by alfcen, Nov 23, 2007.

  1. alfcen

    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

    Code:
    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: Nov 23, 2007
  2. Erel

    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.
     
  3. alfcen

    alfcen Well-Known Member Licensed User

    Thanks a lot, Erel, that ties it.
     
  4. alfcen

    alfcen Well-Known Member Licensed User

    Erel, I worked around with Dimitris' dzHW.dll.
    Recommendation for the hardware library: hardware.GetTickCount
    Cheers
     
Loading...