Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to merge two variables into one in VB 6? 1

Status
Not open for further replies.

Niki_S

Programmer
Jun 4, 2021
232
LK
I have two arrays as below and I want to merge them into one. How can I do that?
Code:
Dim vArray() As Variant
Dim vArray1() As Variant

vArray = oXLSheet.Range("E12:E140").Value
vArray1 = oXLSheet.Range("U12:U140").Value

 cboOperation.Clear
   For lngRow = LBound(vArray, 1) To UBound(vArray, 1)
    If Not IsEmpty(vArray(lngRow, 1)) Then
            cboOperation.AddItem vArray(lngRow, 1)
    End If
   Next lngRow

For lngRow = LBound(vArray1, 1) To UBound(vArray1, 1)
    If Not IsEmpty(vArray1(lngRow, 1)) Then
            cboOperation.AddItem vArray1(lngRow, 1)
    End If
   Next lngRow

Thank You.
 
The 'strep 4' works fine if you apply it to the individual ranges BEFORE you stack them into a single array. So put the step 4 into the vbVStack procedure. Of course then vbVStack won't work for ranges where you don't want to miss data out. Have a think how you might deal with that ...
 
Can I use Skip function for this? If it is so how can I use it?

Thank you.
 
Skip? VB does not have a Skip function. What I was hinting towards was to perhaps try using a "[tt]For next ... Step stepsize[/tt]" loop in the vbVStack function - you might even consider passing [tt]stepsize[/tt] in as a parameter so that you could easily deal with different distributions of valid data in your columns
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top