QB64 Phoenix Edition
Displaying the result - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11)
+--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2)
+--- Thread: Displaying the result (/showthread.php?tid=3681)



Displaying the result - Chris - 05-11-2025

Hello. Is there a way to fix this problem?
A# = 3
PRINT USING "##"; A#
as a result I get "3"
how to modify the line so that the result is "03"
but if A# = 31 it should display "31"

thanks - Chris


RE: Displaying the result - SMcNeill - 05-11-2025

Print Right$("00" + _ToStr$(A#), 2)


RE: Displaying the result - bplus - 05-11-2025

_ToStr$ when did you guys comeup with that? So nice to be rid of Trim$(Str$(mynumber))

PLUS you can control decimal places in decimal numbers!


RE: Displaying the result - Kernelpanic - 05-11-2025

It’s even easier!  Wink

Code: (Select All)

Dim As Integer zahl, zahl2

zahl = 3
zahl2 = 34
Print Using "0# - 0##"; zahl, zahl2

PS: 555 members! That's a *)Schnapszahl, and the boss has to buy us a drink.
*)No meaningful translation available.


RE: Displaying the result - Chris - 05-13-2025

Print Right$("00" + _ToStr$(A#), 2)
result: invalid name.


RE: Displaying the result - SMcNeill - 05-13-2025

(05-13-2025, 08:41 PM)Chris Wrote: Print Right$("00" + _ToStr$(A#), 2)
result: invalid name.

You need the latest version of QB64PE for _ToStr$.

Else use the following on older versions of QB64PE.

Print Right$("00" + _Trim$(Str$(A#)), 2)


RE: Displaying the result - Chris - 05-14-2025

SMcNeill
Great. It works. Thank You very much.
Regards - Chris