Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Displaying the result
#1
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
Reply
#2
Print Right$("00" + _ToStr$(A#), 2)
Reply
#3
_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!
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#4
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.
Reply
#5
Print Right$("00" + _ToStr$(A#), 2)
result: invalid name.
Reply
#6
(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)
Reply
#7
SMcNeill
Great. It works. Thank You very much.
Regards - Chris
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Incorrect result Chris 10 1,710 08-15-2024, 07:43 PM
Last Post: Chris

Forum Jump:


Users browsing this thread: 1 Guest(s)