10-02-2011, 09:12 PM
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!
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!
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!