Back to Gambas

Usar la Propiedad Time

edit

Time returns the current time. Example:

You need 1 button:

Private Sub Button1_click()
   message(time)
end

Te daria algo asi: 22:13:00.998 (En ubuntu me da asi :P)

Por ejemplo si queremos hacer que a determinada hora nos avise, seria algo asi:

Necesitas 2 Textbox, 1 Boton, 1 Timer y un modulo..

En textbox1 escribimos la Hora que queremos que nos avise. En textbox2 escribimos el minuto que queremos que nos avise.

Within the module write:

PUBLIC Hora as string[]
PUBLIC Final as string[]

Within form Fmain, Button1 write:

Private Sub Button1_click()
dim tiempo as String
tiempo=Time
  Module1.Hora=Split(tiempo,":")
    Timer1.enabled = true
   
end
Private Sub Timer1_()
dim tiempo as string
Timer1.delay = 500
  tiempo=Time
    Module1.Final=split(tiempo,":")
    if Module1.hora[0] =  Module1.Final[0] and Module1.hora[1] = Module1.Final[1] then
            message.info("Ya es la hora que ingresaste antes")
            Timer1.enabled = false
    end if
end

Wait Command

edit

The Syntax is

WAIT [ Delay ]

This command calls the event loop. If Delay is specified, it does not return until Delay seconds elapse. Delay is a floating point number. So, if you want to wait 100 ms, just do:

 WAIT 0.1

During the wait, no keyboard or mouse events are processed. Only drawing, timer and file descriptors events, like Process_Write are still running.

Example

You need a commandbutton and a textbox to get it going.

PUBLIC SUB Button1_Click()
 WAIT 10
 'waits 10 seconds 
 WAIT 0.1 
 'waits 100 milliseconds 
 textbox1.Text = ""
END