Visual Basic Reverse Array

In the Visual Basic programming language, we use the Array.Reverse() function to reverse the array, or in other words, to sort the elements in reverse order.

In the example code below, first the correct order of the array and then the reverse order are printed on the screen.

Module ModuleTest Sub Main() Dim arr As String() = {"Ali", "Jack", "Joe", "Jennifer", "Mick"} For Each value As String In arr Console.WriteLine(value) Next Console.WriteLine() Console.WriteLine("Print Reverse") Console.WriteLine() Array.Reverse(arr) For Each value As String In arr Console.WriteLine(value) Next Console.WriteLine() Console.ReadLine() End Sub End Module


You May Interest

Visual Basic Powering a Number

Visual Basic Using String ToCharArray

Visual Basic String Making Lowercase

Visual Basic Get Now

Visual Basic Non-Restart Check If Application is Open