Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6982903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:20:57+00:00 2026-05-27T18:20:57+00:00

How to swap an integer array’s value and index in vb macro i(0 to

  • 0

How to swap an integer array’s value and index in vb macro

i(0 to 5) = {3,4,1,5,0,2}
To
i(0 to 5) = {4,2,5,0,1,3}

editing…

Thankyou @Tim and @Cody

The following function is what i have got, but looking for better and more efficent ways to do it with/without the array l_aiOldIndexSwap

    Public Function SortValuePairs(ByRef l_aiValues() As Integer) As Integer()
     Dim l_aiOldIndexSwap() As Integer
     ReDim l_aiOldIndexSwap(LBound(l_aiValues) To UBound(l_aiValues))
     For i = LBound(l_aiValues) To UBound(l_aiValues)
      l_aiOldIndexSwap(l_aiValues(i)) = i
     Next
     SortValuePairs = l_aiOldIndexSwap
    End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:20:58+00:00Added an answer on May 27, 2026 at 6:20 pm

    Try this

    Dim Result As Integer()
    ReDim Result(5)
    For iLoop = 0 To 5
        Result(i(iLoop)) = iLoop
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: public class Main { static void swap (Integer x,
I have an integer array sorting program here but I have a problem: whenever
i have question from programming pearls problem is following show how to use Lomuto's
we know algorithm how reverse array of n integers for (int i=0;i<n/2;i++){ swap(a[i],a[n-1-i]): }
What is the reason why Wrapper classes (like Integer, Double, etc.) don't have a
There are two integer variables. Can you swap those integer variables without using any
I'm representing an infinitely precise integer as an array of unsigned ints for processing
I have a standard deck of 52 cards is represented in an array. Each
i have the following code that won't compile because of generic problems. It comes
I have the following code: public static <T extends Comparable<T>> T[] getRandomPermutationOfIntegers(int size) {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.