iOS Question Documentation and Timers


Licensed User

Back with another basic question. First is there some documentation that explains timers? Maybe I am missing the documentation pile.

In VB6 you create a timer, set its interval and when you enable it, it will fire after the preset interval. It will keep firing at that interval until you disable the timer.

In B4X I create a timer and I initialize it and it fires immediately before I enable it. I check in the sub used in the initialization and verify that it was not enabled. I said ok I can work with I will just return from the sub if the timer is not enabled. It then appears to not return to the sub after the preset interval. So, obviously I need someone to explain B4X timers. I am sorry to be asking for help on such a basic topic but I have not found the documentation that explains B4X timers.

Thanks for educating m.

Here is my sample code. It jumps to Sequence70Timer_Tick sub as soon as the timer is initialized. Then it returns back to the enable line. It appears not to fire again.


Private Sub SequenceF70Timer_Tick
Log("Sequence F70 Timer= " & tmrF70Sequence.Enabled)
If tmrF70Sequence.Enabled=False Then Return


Licensed User
Longtime User
1. Use [ code ] Your code here [ /code] <-- without the white spaces
2. You use the timer wrong.
3. In B4X IDE, there is a helpful pop up help when you type the keywords.




Clicking the link brings you to

Here is an example code:

Sub Class_Globals
    Private tmrF70Sequence As Timer
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    tmrF70Sequence.Initialize("F70Sequence", 2500)
    'tmrF70Sequence.Enabled = False ' <-- optional because The timer is disabled until the Enabled property is set to true.
End Sub

Sub F70Sequence_Tick
    Log("Sequence F70 Timer= " & tmrF70Sequence.Enabled) ' always true
End Sub

Sub BtnStartTimer_Click
    tmrF70Sequence.Enabled = True
End Sub
Last edited:
Upvote 0