[Gambas-user] Time Help

nando nando_f at ...951...
Mon Jun 13 21:54:27 CEST 2005


An alternate coding for sub Timer1_Timer...

PUBLIC SUB Timer1_Timer()

  INC tick
  IF tick > 9 THEN
    INC sec
    tick = 0
  ENDIF
  IF sec > 59 THEN
    INC mi
    sec = 0
  ENDIF
  IF mi > 59 THEN INC hr
 
  TextBox1.text = Str(hr) & ":" & Str(mi )& ":" & Str(sec) & "." & Str(tick)

END


---------- Original Message -----------
From: Eldon Eller <eeller at ...826...>
To: gambas-user at lists.sourceforge.net
Sent: Mon, 13 Jun 2005 12:36:38 -0700
Subject: Re: [Gambas-user] Time Help

> 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.
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: NEC IT Guy Games.  How far can 
> you shotput a projector? How fast can you ride your desk chair down 
> the office luge track? If you want to score the big prize, get to 
> know the little guy.  Play to win an NEC 61" plasma display:
http://www.necitguy.com/?r=20
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
------- End of Original Message -------





More information about the User mailing list