Search code examples
timerbasic

Timer, Time code, Time format countdown


I read the data from mysql database with command

   vrijeme = myData.Item(2)           ' translation vrijeme = time
           ime = "Dobrodosli " & myData.Item(0) & ""  ' translation ime = name
           GameForma.Show()

After that i store the vrijeme to the textbox with

txtvrijeme.text = vrijeme 

Then i add timer control on form and want to countdown from the time in textbox to 0 .. The time in textbox is in format 00:00:00

Anyway's ill set the entire project in .rar with connection strings and all needed stuffs if anyone want to help Dropbox :https://www.dropbox.com/s/maxmxeak0cr353q/PocetnaVerzija.rar


Solution

  • The solution would be . Read the data from value

        hours = txtTimefromDB.Text.Substring(0, 2)
        minutes = txtTimefromDB.Text.Substring(3, 2)
        sec = txtTimefromDB.Text.Substring(6, 2)
    

    Start decrementing

    Private Sub tmrCountdown_Tick(sender As Object, e As EventArgs) Handles tmrCountdown.Tick
        sec = sec - 1
        If sec = 0 Then
            minutes = minutes - 1
            sec = 60
        ElseIf minutes = 0 Then
            hours = hours - 1
            minutes = 60
        End If
        txtTimefromDB.Text = "" & hours & ":" & minutes & ":" & sec
    End Sub