[Gambas-user] Time Help

Eldon Eller eeller at ...826...
Mon Jun 13 21:36:38 CEST 2005


Try this:

' Gambas class file

PUBLIC hr AS Integer	' hour
PUBLIC mi AS Integer	' minutes
PUBLIC sec AS Integer	' seconds
PUBLIC tick AS Integer	' 10ths of seconds

PUBLIC SUB Form_Open()

   hr=0
   mi=0
   sec=0
   tick=0

END

PUBLIC SUB Timer1_Timer()

   tick=(tick + 1) MOD 10
   sec=(sec -(tick=0)) MOD 60  ' the minus signs are because true is -1
   mi=(mi-((sec=0) AND (tick=0))) MOD 60
   hr=(hr-((mi=0) AND (sec=0) AND (tick=0))) MOD 12

   TextBox1.text=Str(hr)&":"&Str(mi)&":"&Str(sec+tick/10)

END


Michael Murphy wrote:
> I'm trying to modify Jonás Alvarez 's count down program to be a fast
> clock and I'm having trouble changeing the hours. Here's what I got so
> far:
> 
> ______________
> 
> PRIVATE SUB changetime ()
> 
>  'This sub changes the time that is displayed
>   
>   hours = 12  
>   minutes = Int (Int(secs) / 60)
>   
>   textlabel1.Caption = hours & ":" & minutes & ":" & Format (secs -
> minutes * 60)
>  
> END
> 
> PUBLIC SUB Timer1_Timer()
> 
>     secs = secs + 0.1
>     changetime
> 
> END
> 
> _______________
> 
> Above are the two functions that handle the time change. 'hours' is a
> global variable. When I run the program it displays the 'hours' has
> '12' but I can't figure out how to change the hour when the minute is
> more then 59 and I can't figure out how to set miutes to zero, the
> secs work fine and the minutes do change. I've been working on this
> for hours so any help is appreciated. If you need anymore info let me
> know.




More information about the User mailing list