We can give in array as many as 32 dimensional, but in reality we only use 2 or 3

Declaring Array Without Initialized

If we declare it like this

Dim arrValues() As Integer

this means we declare an array without giving the slot, later if we want to give a slot, we can simply write it like this

Redim arrValues(0 to 10)
arrValues(1) = 1000

To redim an array that already fill with value, and we don't want to reset the value, we can simply add Preserve keyworad infront of Redim

Redim Preserve arrValues(0 to 10)

Let's jump out to a sample code

First create a sample form like this

In this form the user will input any kind of string and everytime the user hit the Add button the string value will be saved into the array

And if the user hit the Remove button the string value that already save into the array will be removed one by one according to the order

Public Class Form1
' The array of strings.
Private Values(0 To -1) As String
' Add a string to the array.
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
' Get the old upper bound.
Dim old_upper_bound As Integer = Values.Length - 1
' Make room for the new item.
ReDim Preserve Values(0 To old_upper_bound + 1)
' Insert the new item.
Values(old_upper_bound + 1) = txtString.Text
' Clear the TextBox.
txtString.Clear()
txtString.Focus()
End Sub
' Remove a string from the array.
Private Sub btnRemove_Click(sender As Object, e As EventArgs) Handles btnRemove.Click
' Get the old upper bound.
Dim old_upper_bound As Integer = Values.Length - 1
' Make sure the array isn't empty.
If old_upper_bound < 0 Then
' There are no more items. Say so.
txtString.Text = ""
Else
' Display the last item in the array.
txtString.Text = Values(old_upper_bound)
' Resize the array to remove the last item.
ReDim Preserve Values(0 To old_upper_bound - 1)
End If
End Sub
End Class

Run the project, and try to add some item, after add several item, put a breakpoint in line 17, and hover the mouse over Values in line 14, you will see there are 4 item inside the Values array.

Another great way to create an array and this is my favorite, after defining the array name, use curly bracketto fill the value

Dim TheValues As Integer = {10,23,350,324,500}

Of course you must give a value that correspond with the data type, otherwise it will be crashed.

for this post we will discuss a function that can change every initial letter on a word into uppercase or capslock.

Open a new project (Standard.Exe), in Form1 add a textbox and set the Height and Width property of a rather large size make sure your Multiline property is set to True, so that its textbox can be widened down, and let the Name property match its default name .

Now let's move to editor mode, click View -> Code, and enter the following code :