Qbasicnews.com

Full Version: Appending a number to an Existing number
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
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:
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.
I'd do this:
Code:
number = 5689
num$=LTRIM$(STR$(number))
num$=num$+"1"
number=val(num$)

That should work
...
A = 5378
B = 1
C = 10^CINT(LOG(B)/LOG(10)+.5001)
NEWNUMBER = A * C + B
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:
Quote:A = 5378
B = 1
C = 10^CINT(LOG(B)/LOG(10)+.5001)
NEWNUMBER = A * C + B

retard.
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]
Quote:
Glenn Wrote:A = 5378
B = 1
C = 10^CINT(LOG(B)/LOG(10)+.5001)
NEWNUMBER = A * C + B

retard.

HAHAHAHAH
Quote:
Glenn Wrote:A = 5378
B = 1
C = 10^CINT(LOG(B)/LOG(10)+.5001)
NEWNUMBER = A * C + B

retard.
Pages: 1 2 3