[Gambas-user] gb3: Format$

Benoît Minisini gambas at ...1...
Sun Jun 26 20:52:12 CEST 2011


> That makes perfect sense and was the expected behavior. I'm not sure
> what's happening here, but this test code:
> 
> Public Sub Main()
> 
>    Dim t As Float
> 
>    t = CFloat(Now) ' Current time and date.
> 
>    Print "1: CDate(t):                         " & CDate(t)
>    Print "2: Format$(CDate(t), \"hh:nn:AM/PM\"): " & Format$(CDate(t),
> "hh:nn:AM/PM")
>    Print "3: CDate(t):                         " & CDate(t)
>    Print "4: Format$(CDate(t), \"hh:nn:AM/PM\"): " & Format$(CDate(t),
> "hh:nn:AM/PM")
>    Print "5: CDate(t):                         " & CDate(t)
> 
> End
> 
> Produces these results:
> 
> 1: CDate(t):                         06/25/2011 18:35:46.837
> 2: Format$(CDate(t), "hh:nn:AM/PM"): 06:35:PM
> 3: CDate(t):                         06/25/2011 06:35:46.837
> 4: Format$(CDate(t), "hh:nn:AM/PM"): 06:35:AM
> 5: CDate(t):                         06/25/2011 06:35:46.837
> 
> I checked, and the value of variable "t" is not being changed. However,
> after the first Format$, CDate(t) returns a different value than before
> the first Format$. Any idea why? Lines 1 and 2 look good, but it seems
> like lines 1 and 3 should print the same value. Somehow the Format$ line
> continues to have an effect on the subsequent lines.
> 
> I hope I'm really not so stupid that I'm missing something obvious. I'm
> not even drinking right now!

Mmm... You're right, there's something nasty there. I'm currently 
investigating...

-- 
Benoît Minisini




More information about the User mailing list