BP Forums
Integer Arrays! - Printable Version

+- BP Forums (https://bpforums.info)
+-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55)
+--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56)
+---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8)
+----- Forum: Code Snippets (https://bpforums.info/forumdisplay.php?fid=18)
+----- Thread: Integer Arrays! (/showthread.php?tid=406)



Integer Arrays! - brandonio21 - 10-02-2011

I recently did a java tutorial on integer arrays, so I thought that I'd post the vb.net version of the code as well!
Code:
Public Sub Execute()
        Dim arrInt(5) As Integer 'Creates an integer array with 5 slots

        arrInt(0) = 1 'Assigns a value of 1 to the first slot in the array
        Dim i As Integer = 0 'Creates an integer, i, and gives the initial value of 0
        Do While i < 5 'While i is 0-4
            arrInt(i) = i + 1 'Tell the corresponding slot in the array to be equal to i+1, so if i was 3, arrInt(3) would be set to 4
            i = i + 1 'Increase the value of i by 1
        Loop
        MsgBox(arrInt(0).ToString + " " + arrInt(1).ToString + " " + arrInt(2).ToString + " " + arrInt(3).ToString + " " + arrInt(4).ToString) 'Convert all the array values to strings, and display them in a messagebox
    End Sub

After posting this little code snippet, I realized that I never really created a video explaining Arrays in vb.net. Since arrays are extremely useful, I may be doing a tutorial on this soon!