Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to convert from Integer into String ? Please help...
#1
How to convert the following:

a0 = 0
a1 = 88.28

into

a$ = "0 - 88.28"

Thanks
Reply
#2
Code:
a$ = ltrim$(str$(a0)) + " - " + ltrim$(str$(a1))
Reply
#3
Thanks, Plasma
Reply
#4
For the record, here are four useful functions:
Code:
VAL (s$). s$ is a string expression that you want to convert to a number. For example VAL("11162.723dd") returns 11162.723.
STR$(n). Returns the string that represents the numeric expression passed. For example, STR$(11512.661) returns "11512.661".
LTRIM$(s$). s$ is a string expression. Returns the string passed, except stripped of any leading spaces.
RTRIM$(s$). Exactly the same as LTRIM$(), except strips the spaces on the end of the string, not the beginning.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#5
Quote:For the record, here are four useful functions:
Code:
VAL (s$). s$ is a string expression that you want to convert to a number. For example VAL("11162.723dd") returns 11162.723.
STR$(n). Returns the string that represents the numeric expression passed. For example, STR$(11512.661) returns "11512.661".
LTRIM$(s$). s$ is a string expression. Returns the string passed, except stripped of any leading spaces.
RTRIM$(s$). Exactly the same as LTRIM$(), except strips the spaces on the end of the string, not the beginning.

Correction:

Code:
STR$(n). Returns the string that represents the numeric expression passed. For example, STR$(11512.661) returns " 11512.661".

That is why the LTRIM$ is required.
Reply
#6
Very true, forgot about that...
I guess that's space for the sign?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#7
Indeed it is. pretty silly really, they should make the space for the sign only appear if it is negative. But i suppose it is required to identify positive signed numbers.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)