?
Solved

move array from the last dimention

Posted on 2006-04-13
5
Medium Priority
?
159 Views
Last Modified: 2010-05-01
Hi,

Please kindly assist how can we move emelemnts of an array one step to the right?
i.e.

arr=1,2,3,4,5,empty


output desired:
arr=empty,1,2,3,4,5


Thanks.
0
Comment
Question by:RyanBank
  • 2
  • 2
5 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 16446334
dim l as long
dim s as long

s = arr(ubound(arr))
for l = ubound(arr) to lbound(arr)+1
  arr(l) = arr(l-1)
next
arr(lbound(arr)) = s

0
 

Author Comment

by:RyanBank
ID: 16446550
got it!!

                For x = UBound(Arr_Req) To i + 1 Step -1
                    Arr_Req(x) = Arr_Req(x - 1)
                Next x
Thanks!
0
 
LVL 8

Expert Comment

by:Leo Eikelman
ID: 16446572
I don't think that would actually work.

You would need to do something like this
dim l as long
dim s as long

s = arr(UBound(arr))
previousNew = arr(l)
For l = LBound(arr) To UBound(arr) - 1
  previousOld = arr(l + 1)
  arr(l + 1) = previousNew
  previousNew = previousOld
Next
arr(LBound(arr)) = s


Cheers,

Leo
0
 
LVL 8

Expert Comment

by:Leo Eikelman
ID: 16446582
.. or that would work too... haha
0
 

Author Comment

by:RyanBank
ID: 16446608
leikelman

thanks for your time and patience.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question