33- Arrays


This Visual Basic tutorial is all about Arrays.
What is an Array?  Array is a sequence of objects that has similar type and size. Every object inside an array is defined as the element of an array. It’s either you have an array of strings or characters, integers or any that has defined data type.


The main purpose of an array is to organize identical data together as a team to execute operations on data in a collective manner.




Let’s begin:

Take note that arrays is accessed by their index number and it always starts from zero.

  • Open the Visual Basic, select “File” on the menu, hit new and create a new project.
  • The New Project dialog will appear.
    Select “windows” in the project types, hit the “windows form application” in the templates and hit “ok“.
  • In the toolbox, select a button and drag it into the form.
  • Add the following code in the code editor.
    1. 'declare array as a string with six index
    2. Dim tagline(6) As String
    3. 'assigning values to an array
    4. tagline(0) = "itsourcecode.com"
    5. tagline(1) = " We Exist to Provide"
    6. tagline(2) = "Best Quality"
    7. tagline(3) = " and 100% Free"
    8. tagline(4) = " Source Code"
    9. tagline(5) = "and"
    10. tagline(6) = "Tutorials!"
    11. 'retrieving value of an array
    12. MsgBox(tagline(6))


Press f5 to run your project.


Readers might read also:



Facebook Comments


Please enter your comment!
Please enter your name here