Android Question Minute and Hour to Ticks


Active Member
Licensed User
Hello, i have a script to calculate the ticks and the right day from minute and hour:

Sub getTime(minuteHour As String) As Long
        Dim hour, minute As Int
        Dim a() As String = Regex.Split(":", minuteHour)
        hour = a(0)
        minute = a(1)
        Dim today, alarms As Long
        today = DateTime.DateParse(DateTime.Date(DateTime.Now)) 'Sets today at 12:00 AM
        alarms = today + hour * DateTime.TicksPerHour + minute * DateTime.TicksPerMinute
        If alarms < DateTime.Now Then alarms = DateTime.Add(alarms, 0, 0, 1)
        Log(DateTime.Date(alarms) & " " & DateTime.Time(alarms)) 'check the logs to see the set date and time
        'Calculate time to alarm
        Dim h, m As Int
        h = Floor((alarms - DateTime.Now) / DateTime.TicksPerHour)
        m = ((alarms - DateTime.Now) - h * DateTime.TicksPerHour) / DateTime.TicksPerMinute
        Return (DateTime.Now+((h*60*60*1000)+(m*60*1000)))   
End Sub

But this script varies 50 seconds ca.