devxlogo

SwapArrayItems – Swap two elements in the input array

SwapArrayItems – Swap two elements in the input array

' Swap two elements in the input array'' Example:'   Dim arr As Integer() = {3, 7, 8, 2, 0, 9}'   SwapArrayItems(arr, 1, 4)'   Dim o As Object'   For Each o In arr'       Debug.Write(o & " ")'   Next'   Debug.WriteLine("")Sub SwapArrayItems(ByVal arr As Array, ByVal index1 As Integer, _    ByVal index2 As Integer)    Dim temp As Object = arr(index1)    arr(index1) = arr(index2)    arr(index2) = tempEnd Sub

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist