• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 163
  • Last Modified:

move array from the last dimention

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
RyanBank
Asked:
RyanBank
  • 2
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
RyanBankAuthor Commented:
got it!!

                For x = UBound(Arr_Req) To i + 1 Step -1
                    Arr_Req(x) = Arr_Req(x - 1)
                Next x
Thanks!
0
 
Leo EikelmanDirector, IT and Business DevelopmentCommented:
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
 
Leo EikelmanDirector, IT and Business DevelopmentCommented:
.. or that would work too... haha
0
 
RyanBankAuthor Commented:
leikelman

thanks for your time and patience.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now