You are here:

# Qbasic, Quickbasic/merging

Question
QUESTION: how can we put the values of two arrays in the third array without merging them

If you are combining two arrays, that is the same as merging them, so I'm not sure what you mean by "without merging them."  Do you mean you want the arrays sorted, or combined in a certain way?

Take care,
-Alex

---------- FOLLOW-UP ----------

QUESTION: i want to combine two arrays into one array
suppose take arrays A,B and C.i want to put the values of array A and array B  without sorting them.hope you will be able to answer my question

Hi again :)

This is how I'd approach it:

```DIM first(1 TO 10) AS INTEGER
DIM second(1 TO 30) AS INTGER
REDIM combined(0) AS INTEGER

'' Fill first and second up with a bunch of numbers/values here...(not shown)

'' Get the size of the first and second array, and add them together to get the total number of elements
combined_size% = (UBOUND(first)-LBOUND(first)+1) + (UBOUND(second)-LBOUND(second)+1)
'' Resize the combined array so it can hold all of the values of first and second
REDIM combined(1 TO combined_size%) AS INTEGER

c% = 1 '' Our counter for the combined array index
FOR i% = LBOUND(first) to UBOUND(first)
combined(c%) = first(i%)
c% = c% + 1
NEXT i%
FOR i% = LBOUND(second) TO UBOUND(second)
combined(c%) = second(i%)
c% = c% + 1
NEXT i%

'' Print out all the values of combined()
FOR i% = LBOUND(combined) TO UBOUND(combined)
PRINT "combined("; i%; ") = "; combined(i%)
NEXT i%```

That should do it for you :)

-Alex

Qbasic, Quickbasic

Volunteer

#### Alex Barry

##### Expertise

I have been a qbasic programmer since 2000, creating games, minor libraries and various small programs. I have experience using interrupts, graphics, file input/output, the mouse cursor, and using libraries. I have also learned FreeBASIC, QB64, c/c++, python, lua, php and html.
I do not claim to be an absolute authority in any language, but I don't mind looking things up and learning with you.

##### Experience

I have been programming in *Basic dialects since 2000, as mentioned in my expertise. After a year of QBasic, I learned C and C++, and dabbled a little in ASM (I don't program in ASM - I literally just played around to see how things work). When QB64 and FreeBASIC were released, I played with those languages. At the time, FreeBASIC offered more functionality and I sided with that language for a while. During that time, while I was learning new languages, that I would see what scripting languages are available, where I took up python and lua. I started to notice a staleness to QB64's development (which I kept tabs on from time to time), and am now trying to be active in it's community and maybe in it's development in the future. Currently, I am only active on the QB64.net forums, but I appear on occasion on FreeBASIC.net's forums as well.

Education/Credentials
Highschool - 2007