[Gambas-user] Need help on format$ function

Benoit Minisini gambas at ...1...
Sun Nov 28 18:51:32 CET 2004


On Friday 26 November 2004 20:14, Bodard Fabien wrote:
> Hi to all
>
>
> I'm working on a professionnal program for manage cognac stock...
>
> But when i type :
>
> PRINT Format(12355.20, "0 00.00")
>
> i've :
>
> 12355 00.00
>
>
> I need somme thing like that :
>
> PRINT Format(12355.20, "0 \h\l 00 \L .00 \c\l")
>
> it don't work (escape characters are not accepted) but it will be usefull
> and must to return :
>
> 123 hl 55 L. 20 cl
>
>
> If i type
>
> PRINT Format(12355.20, "0 hl 00 L .00 cl")
>
> it return :
> 12355 hl 00 L .00 cl
>
>
>
> Say me if you have a soluce for that please !
>
>
> Fabien Bodard
>
>

The Gambas Format$() function does not work like the other Basic ones.

You can only use formatting characters in the format string: no spaces, no 
alphabetical character. And you can't split the formatted values with 
separators.

Maybe I will enhance Format$() this way in the future. But at the moment, you 
must split the string yourself:

sFormat = Format(12355.20, "00000")
PRINT Left$(sFormat, 1); " hl "; Mid$(sFormat, 2, 2); " L ."; Mid$(sFormat, 4, 
2); " cl"

Sorry for the little extra job ! :-)

-- 
Benoit Minisini
mailto:gambas at ...1...




More information about the User mailing list