[Gambas-user] Timer
Rolf-Werner Eilert
rwe-sse at ...3629...
Fri Jan 27 15:33:18 CET 2017
Hi,
>
> The program has a form with 3 buttons and a valuebox.
> Button 1 starts timer.
> Button 2 stops timer.
> Button 3 restarts timer.
Restart? What for, you have Button 1... Or do you mean "resume"?
>
> As usual I just cannot get the syntax correct to make it work.
> When I copy/paste from the help browser still not right!
>
> I really want to like and use Gambas but am put off by the unclear help and lack of very simple examples.
I agree, that could be improved. You're welcome to help ;)
> ' Gambas class file
>
> Public Sub Form_Open()
>
>
>
> End
>
> Public Sub Timer1_Timer()
>
> ValueBox1.Value = Timer1
>
>
> End
Hm, guess you got this Timer thing wrong. As soon as activated, Timer
will just run and the program will jump into the Timer event each time
it "ticks" (the time you adjust, e. g. 1000 ms for 1 second).
So, if you want your clock to tick every second, make a counter variable
for the whole class file and set
Inc MyCounterVariable
within the Timer1_Timer() event and let the clock show it.
Public Sub Timer1_Timer()
Inc MyCounterVariable
'show the value in this line
End
For the beginning, use a Label to show the value.
> Public Sub Button1_Click()
>
> Timer1.Enabled = True
>
> End
>
>
>
> Public Sub Button2_Click()
>
>
>
> End
>
> Public Sub Button3_Click()
>
>
>
> End
>
>
>
Won't be back before Monday, but hope it helps :)
Regards
Rolf
More information about the User
mailing list