Posts: 3
Threads: 1
Joined: Apr 2003
Hi, I am just learning QBasic. Is there a way to do this?
Let's say I have the number 5378 and I want to append the number 1 to the end 5378 without any spaces. Can this be done.
For Example
Number.......Append.............New Number
5378..............1 .......................53781
By the way these numbers are not strings, they are numeric.
I tried doing PRINT 5378;1 but this results in 5378 1. I do not want a space in between the 8 and the 1.
:roll:
Posts: 3,368
Threads: 195
Joined: Jan 2003
It cannot be done without a string unless you do
PRINT 5378# * 10 + 1
otherwise,
PRINT val(ltrim$(str$(5378))+ltrim$(str$(1)))
str makes the number a string and adds a space in front of it.
ltrim removes the space.
val makes the string a number.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 1,166
Threads: 62
Joined: Apr 2003
I'd do this:
Code:
number = 5689
num$=LTRIM$(STR$(number))
num$=num$+"1"
number=val(num$)
That should work
am an asshole. Get used to it.
Posts: 3,368
Threads: 195
Joined: Jan 2003
...
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
Posts: 704
Threads: 0
Joined: Dec 2002
A = 5378
B = 1
C = 10^CINT(LOG(B)/LOG(10)+.5001)
NEWNUMBER = A * C + B
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Posts: 3
Threads: 1
Joined: Apr 2003
Thanks I'll try your suggestions. I am not in a hurry for it so I'll play with it a while until I'm bald again then I'll come back to beg for help. :rotfl:
Posts: 720
Threads: 46
Joined: Oct 2001
Quote:A = 5378
B = 1
C = 10^CINT(LOG(B)/LOG(10)+.5001)
NEWNUMBER = A * C + B
retard.
Posts: 3
Threads: 1
Joined: Apr 2003
This Code was what I was looking for. Thanks so much. My brain must of been on overload because the answer was so simple.
[PRINT 5378# * 10 + 1]
Posts: 1,166
Threads: 62
Joined: Apr 2003
Quote:Glenn Wrote:A = 5378
B = 1
C = 10^CINT(LOG(B)/LOG(10)+.5001)
NEWNUMBER = A * C + B
retard.
HAHAHAHAH
am an asshole. Get used to it.
Posts: 704
Threads: 0
Joined: Dec 2002
Quote:Glenn Wrote:A = 5378
B = 1
C = 10^CINT(LOG(B)/LOG(10)+.5001)
NEWNUMBER = A * C + B
retard.
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.