19/05/2023: A causa di un errore sono stati cancellati, insieme ad account creati da bot, alcuni account legittimi. Si prega di leggere qui: https://www.gambas-it.org/smf/index.php?topic=9733.0
Private $hTime As DatePrivate $sTime As StringPrivate $hTimer As TimerPublic Sub Form_Open() Dim hButton As Button With Me .W = 240 .H = 152 .Margin = True .Arrangement = Arrange.Fill End With With hButton = New Button(Me) As "Button1" .Text = "Avvia il confronto Time" End With With $hTimer = New Timer As "Timer1" .Delay = 1000 .Ignore = True End WithEndPublic Sub Timer1_Timer() Dim hNow As Date = Time(Now) Dim sNow As String = Format(hNow, "hh:nn:ss") Print hNow;; $hTime ''If hNow = $hTime Then '' perché questo non funziona? :-/ If sNow = $sTime Then '' e invece questo funziona ma... Print "UGUALE" $hTimer.Stop EndifEndPublic Sub Button1_Click() $hTimer.Start $hTime = Time(Hour(Now), Minute(Now) + 1, 0) $sTime = Format($hTime, "hh:nn:ss")End
Private $hTimer As TimerPrivate $iHour As IntegerPrivate $iMinute As IntegerPublic Sub Form_Open() Dim hButton As Button With Me .W = 240 .H = 152 .Margin = True .Arrangement = Arrange.Fill End With With hButton = New Button(Me) As "Button1" .Text = "Avvia il confronto Time" End With With $hTimer = New Timer As "Timer1" .Delay = 1000 .Ignore = True End WithEndPublic Sub Timer1_Timer() Dim iHour As Integer = Hour(Now) Dim iMinute As Integer = Minute(Now) Print iHour; ":"; iMinute;; $iHour; ":"; $iMinute If iHour = $iHour And If iMinute = $iMinute Then Print "UGUALE" $hTimer.Stop EndifEndPublic Sub Button1_Click() $hTimer.Start $iHour = Hour(Now) $iMinute = Minute(Now) + 1End
Penso che tu non consideri i millisecondiSe formatti il tuo tempo con la stringa "hh:nn:ss.uuu" vedrai che hNow e $hTime sono diversi
Private $hTime As DatePrivate $hTimer As TimerPublic Sub Form_Open() Dim hButton As Button With Me .W = 240 .H = 152 .Margin = True .Arrangement = Arrange.Fill End With With hButton = New Button(Me) As "Button1" .Text = "Avvia il confronto Time" End With With $hTimer = New Timer As "Timer1" .Delay = 1000 .Ignore = True End WithEndPublic Sub Timer1_Timer() Dim hNow As Date = Time(Now) Print DateDiff($hTime, hNow, gb.Second) If DateDiff($hTime, hNow, gb.Second) = 0 Then Print "UGUALE" $hTimer.Stop EndifEndPublic Sub Button1_Click() $hTimer.Start $hTime = Time(Hour(Now), Minute(Now) + 1, 0)End