VB.NET Array Reverse Example – Code Sample Syntax

Pluralsight courses
LinkedIn Premium uses PayScale to estimate job salaries

Premium (Not Free) Video Tutorials

Free Video Tutorials & Free Tools

VB.NET ArrayReverse Example – Code Sample Syntax

Abstract: – Illustrates using .



 

 


 *** 1. Download Source Code *** 

VB.NET Syntax DataStructures ArrayReverse download Download Source Code for All VB Console Examples in One Project

 


 *** 2. ArrayReverse Syntax *** 


Purpose:
Reverses the order of elements in an array


Syntax:
arrayname.Reverse

Parameters Description
Parameter1 specifies number of elements in array

Result Data Type Description
array contains a set of elements in the array in reverse order



 *** 3. ArrayReverse – Quick Example *** 

Dim aryAuthors(2) As String
aryAuthors(0) = "Plato"
aryAuthors(1) = "Aristotle"
aryAuthors(2) = "Hume"
Array.Reverse(aryAuthors)

 

 


 *** 4. ArrayReverse – Full Example *** 

ArrayReverse Example Output Screenshot

VB.NET Syntax DataStructures ArrayReverse screenshot

Step 1: Click Visual Basic to Cut-n-paste code into clsArrayReverse.vb

 Visual Basic |  copy code |? 
Public Class clsArrayReverse
    Public Sub Main()
 
 
        '****************************************************************************************
        '
        ' Purpose: Reverses the order of elements in an array
        '
        ' Syntax: 	arrayname.Reverse
        '
        ' Result: array - contains a set of elements in the array in reverse order
        '
        ' Quick Example: Dim aryAuthors(2) As String
        ' aryAuthors(0) = "Plato"
        ' aryAuthors(1) = "Aristotle"
        ' aryAuthors(2) = "Hume"
        ' Array.Reverse(aryAuthors)
        '
        '****************************************************************************************
        ' This example is from http://idealprogrammer.com
 
        '****************************************************************************************
        Console.WriteLine("Example #1: Dim aryAuthors(2) As String")
        '****************************************************************************************
 
        Dim aryAuthors(2) As String
        ' we start with elements in alphabetical order and then reverse
        aryAuthors(0) = "Aristotle"
        aryAuthors(1) = "Hume"
        aryAuthors(2) = "Plato"
        Array.Reverse(aryAuthors)
 
 
 
        For Each myElement In aryAuthors
            Console.WriteLine(myElement) ' Returns elements in reverse
        Next
 
 
 
 
 
 
        'Prevent console from closing before you press enter
        Console.ReadLine()
 
    End Sub
 
End Class
 
 
 
 

Step 2: Click Visual Basic to Cut-n-paste code into Module1.vb
 Visual Basic |  copy code |? 
Module Module1
 
    Sub Main()
 
 
        Dim myclsArrayReverse As New clsArrayReverse
        myclsArrayReverse.Main()
 
 
 
    End Sub
 
End Module
 
 
 
 

Prerequistes:

  1. Install Visual Basic (Express or Standard Edition)
  2. Install SQL Server Express
  3. Download Northwind and pubs Database
  4. Attach Northwind Database to Databases in Sql Express
  5. Attach pubs Database to Databases in Sql Express

Notes:

  • Console Application is used to simplify things, but Windows Forms or Web Forms could also be used
  • You can build a library of syntax examples by using same project over and over and just commenting out what you do not want to execute in Module1.vb

Instructions:
VB.NET Syntax DataStructures ArrayReverse

  1. Use Visual Basic 2010 Express or Standard Edition
  2. Create new project;
    • Click File/New Project
    • Select Console Application Template
    • Select Visual Basic for Language
    • name of project could be VBNET_Syntax.
  3. Add New folder named "DataStructures"
    • Right-click project name in solution explorer;
    • add new folder;
    • name of folder could be: DataStructures
  4. Add Class Named clsArrayReverse to DataStructures folder
    • Right-click DataStructures folder;
    • add new item;
    • Select class
    • Class name could be clsArrayReverse
  5. Click on Visual Basic in code in step 1 above to copy code into clsArrayReverse.vb
  6. Click on Visual Basic in code in step 2 above to copy code into Module1.vb
  7. Click green arrow or press F5 to run program

Related posts:

  1. VB.NET Array: One Dimensional Example – Code Sample Syntax VB.NET Array One-Dimensional Example - Code Sample Syntax...
  2. Array Example – Data Type – JavaScript Syntax – JS Array Example Array Example - Data Type - JavaScript Syntax - JS...
  3. VB.NET StrReverse() – Code Sample Syntax Example VB.NET StrReverse() - Code Sample Syntax Example...
  4. VB.NET Log Example – Code Sample Syntax VB.NET Log Example - Code Sample Syntax...
  5. VB.NET Exp Example – Code Sample Syntax VB.NET Exp Example - Code Sample Syntax...

Related posts brought to you by Yet Another Related Posts Plugin.

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

Powered by WP Hashcash

This blog uses the cross-linker plugin developed by Web-Developers.Net