question about concatenation

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Bojangles

question about concatenation

Post by Bojangles »

I have two values and 2 string$ variables I need to concatenate. It doesn't like it. I have year day line$ and run$ and I need then as 1 value or string. I tried let lot$ = year + day + line$ + run$ but no dice. Any way to join these items as 1?
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Uhhh

Post by {Nathan} »

thats kinda confusing, but i might know wut u wanna do. if some of thes little things you are tying to add are integers, then just use MK... uhh... i dunno wut the exact thing is, but it starts with mk. you con convert integers, singles, doubles to string. hope that helps!!! :? :? :?
Image
Bojangles

Post by Bojangles »

2 are values 2 are string but I want to end up with 1 printable string. Here's the example. year = 4 day = 242 line$ = 26 run$ = 1 Year and day are calculated, line and run are entered. I need 1 printable string out of that , that is 4242261.
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

i...can...hELP

Post by {Nathan} »

just do it like this

PRINT Varible1, Varible2

ect
easy, eh?
Anonymous

Post by Anonymous »

Er... no.

The way Nathan1993 suggested will have 4 or more spaces between the variables.

Here's the way to do it:

Code: Select all

lot$ = LTRIM$(STR$(year)) + LTRIM$(STR$(day)) + line$ + run$
PRINT lot$
STR$ converts a number variable (integer, long, single, double) to a string. If the number is positive, it will have one space in front. That's why I use LTRIM$ as well. It removes spaces at the front of a string.

Hope it helped... again ;)


And Nathan1993:
Nathan1993 wrote:then just use MK... uhh... i dunno wut the exact thing is, but it starts with mk.
You must mean MKI$, MKL$, MKS$ and MKD$. But these are not used for converting numbers to numerical strings. They are for converting numbers to strings bitwise. So if you have a number 666 and you make a string out of it using MKI$, you'll get CHR$(&H9A) + CHR$(02).

So, use STR$. Then the number 666 will just become " 666".

;)
Bojangles

Post by Bojangles »

Thanks again. That's why I come to the pros. I was offline due to the Hurricane. We took quite a hit and doubt we could survive another. If Ivan comes, I may not be back at all.
Anonymous

Post by Anonymous »

No problem :)

Hurricanes are bad. I hope you'll survive any hurricane that passes by!
Post Reply