 Everybody this is Brian and this is our twelfth visual basic tutorial today. We're going to be discussing arrays So what is an array? Well an array is multiple objects That have the same name. I know that sounds a little confusing and I know that looks very confusing What are we doing here? We're creating a variable as an integer, but no we're actually creating four of them But I typed three. Let's find out why That's how you access an array Arrays are zero based and when you create an array you're giving it the upper bound So there's actually four zero one two three four, and I'll I'll go ahead and Type all this out so you can see what I mean here mouse doesn't want to work And we'll say 200 300 400 This is the L bound or lower bound of the array. This is the U bound or upper bound of the array Arrays are zero based. We gave it the upper bound three So there's going to be four positions in this array Now the reason why I'm using plate is this is how I learned arrays as you think of an array as a dinner table the dinner table itself is the array and the the variables inside of that or dinner plates and Then you know the value is you know the number of carrots or something they have on the plate, so Whoever has plate three must be very hungry Why would you use an array? Why wouldn't you just make you know? Four different variables. Well the reason is very simple once you get into programming you start using massive Numbers for example, let's say you have five thousand plates Well, you don't want to write out five thousand variables. You'd rather just use an array and you'd say like Tim index as integer and we're going to say for index Equal L bound plate to U bound plate Now that looks a little more confusing. You've seen the for loop before What we're saying is we have a index an integer The index is also the index within the array So we're saying for index equals We're looping here L bound To you about so we're gonna go L bound this one this one and then you bound And then console dot right line and we're going to say plate Index is and we'll say Plate and we're going to access that Using our index That should be a little more clear what this does Apologize for This taking up too much screen real estate here. We're saying we have four items in this array It's you bound is three. I know that's confusing. Just remember the zero is always plus one and Then we're going to say for each item in that array starting at the L bound ending in the U bound print out the Plate the position and then the value and you access the value Using the parentheses and then the index you want to find it at Let's run this Whoop build errors Let's see what we did here Mmm. Yes. This is the fine art of debugging We've never gone over debugging so we should cover it pretty quick here It says that we're missing a parentheses at the end and it even shows you What it should look like, but it's off the edge of the screen, but Let's go ahead and add parentheses at the end hide that And let's run it and see what happens now our project works as expected You can see plate zeros a hundred plate ones 200 plate twos three Plate three is four That is why you would use an array Now I'm running out of time here, but I want to show you what happens if you try to access Part of the array that doesn't exist Let's say you want to just tack one on here real quick That won't work. See index is out of out of range exemption Index is out of the bounds of the array. See we have a lower bound and an upper bound You gave it an upper bound of three you're trying to access something So you're saying that there's another person at that dinner table that just quite frankly doesn't exist So I know that was a bit confusing. I would actually recommend you rewind this video Start it from scratch if you're not typing along. I recommend that you type this out and fully understand it Rays are very important All right, I hope you found this video educational and entertaining and thank you for watching