Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Appending a number to an Existing number
#1
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:
Reply
#2
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.
Reply
#3
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.
Reply
#4
...
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.
Reply
#5
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.
Reply
#6
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:
Reply
#7
Quote:A = 5378
B = 1
C = 10^CINT(LOG(B)/LOG(10)+.5001)
NEWNUMBER = A * C + B

retard.
Reply
#8
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]
Reply
#9
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.
Reply
#10
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)