Quantcast

Timer

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Timer

j h-7
I need help with a simple Stopwatch program in Gambas 3.9.2


The program has a form with 3 buttons and a valuebox.
Button 1 starts timer.
Button 2 stops timer.
Button 3 restarts timer.

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. 

Here is where I Went delete happy then gave up.






' Gambas class file

Public Sub Form_Open()

 

End

Public Sub Timer1_Timer()

  ValueBox1.Value = Timer1
 

End

Public Sub ValueBox1_MouseDown()




End



Public Sub Button1_Click()

Timer1.Enabled = True

End



Public Sub Button2_Click()

 

End

Public Sub Button3_Click()

 

End





Any help would help.
Ta.







------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Timer

Rolf-Werner Eilert-2
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



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Timer

Jussi Lahtinen
In reply to this post by j h-7
It's much easier to help you with your project, if you would put the whole
thing as attachment.
Select from the menu: Project --> Make --> Source archive
And then attach the result to your mail.


Jussi

On Fri, Jan 27, 2017 at 3:51 PM, j h <[hidden email]> wrote:

> I need help with a simple Stopwatch program in Gambas 3.9.2
>
>
> The program has a form with 3 buttons and a valuebox.
> Button 1 starts timer.
> Button 2 stops timer.
> Button 3 restarts timer.
>
> 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.
>
> Here is where I Went delete happy then gave up.
>
>
>
>
>
>
> ' Gambas class file
>
> Public Sub Form_Open()
>
>
>
> End
>
> Public Sub Timer1_Timer()
>
>   ValueBox1.Value = Timer1
>
>
> End
>
> Public Sub ValueBox1_MouseDown()
>
>
>
>
> End
>
>
>
> Public Sub Button1_Click()
>
> Timer1.Enabled = True
>
> End
>
>
>
> Public Sub Button2_Click()
>
>
>
> End
>
> Public Sub Button3_Click()
>
>
>
> End
>
>
>
>
>
> Any help would help.
> Ta.
>
>
>
>
>
>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Timer

Charlie
In reply to this post by j h-7
Hi j h-7,

I have created what I think you are looking for, have a look at the attached program.

Stopwatch.tar

Check out www.gambas.one

Loading...