Hi, I'm Bob Tabor with Developer University and I welcome you to this course covering the fundamentals of the visual basic programming language. And we're going to talk about programming topics in general. This is designed specifically for absolute beginners to programming. Now, if you're already an experienced software developer coming from another software development platform or programming language, then frankly this series of lessons might move much too slowly for you. You might be better served finding another resource to use as a starting point, one that has you the experienced beginner to visual basic in mind. Microsoft Virtual Academy has many great courses designed for people at all skill levels. So I recommend that you start your search for the level of course that's right for you at Microsoft Virtual Academy. However, if you are completely new to programming and you're new to the visual basic programming language and you're new to building applications on the Windows platform, then this perhaps is the best place for you to start. Not only will you and I work together to learn the syntax of visual basic, but I'm going to take the time to walk through everything that we do together. One other quick caveat before we get started here. This flavor of visual basic is not for creating macros in Excel or other Microsoft Office tools. That's actually an entirely different tool called visual basic for applications or VBA. Yes, visual basic and visual basic for applications will look similar in some ways, but what you can do with them is extremely different. So if automating Microsoft Office applications is your end goal, then I strongly recommend that you research on Microsoft Virtual Academy for courses related to visual basic for applications or VBA. I'm sure you'll find what you're looking for there. But assuming that you know that you want to work in visual basic proper and build .NET applications, then you're in the right place. I'll explain what we're doing, but more importantly, I'm going to explain why we're doing it, the thought process behind what we're doing. I'm going to try to anticipate the questions that you might have, anticipate the problems that you might run into as you're typing your very first lines of code into the code editor and visual studio or as you're working through some of the exercises that we're going to work through together. Now I've literally taught hundreds of thousands of people visual basic over the past 14 years. That's actually no exaggeration. This includes children as young as eight years old and as young as 80 years old from virtually every corner of the world. They've all learned from a version of the very course that you're watching right now, a previous version of this course. And I know that you can use this course to learn too. In fact, this is the sixth iteration of this course that I'm teaching dating all the way back to 2005. And over the years, I've incorporated the feedback from thousands of students feedback and suggestions on how to improve the course. And I've incorporated those in the in the effort of putting forth the very best course that I possibly could to help you get started and get your feet wet in visual basic. So I only make one real assumption as we begin this course and that's that you already have some version and addition of visual studio installed on your local computer and that you're ready to write your very first lines of code. So if you don't already have visual studio installed, then please, by all means, visit visual studio.com where you're going to learn about many of the free and commercial versions of visual studio that are available and what the differences are. Now personally, in this course and what I use when I'm not recording videos is the visual studio 2015 community edition. It's one of the free versions that you'll find on visual studio.com. You can see it in this particular version of their website right here with this green button you can get started downloading community 2015. But I want to emphasize that you can use any addition and any version of visual basic with the lessons that I'm going to teach. There might be tiny user interface differences between what you see on my screen and what you see on your screen. However, I think you're going to find that as you work through the videos, there's really no difference in the language itself. I'm not going to be focusing on any of the specific features of visual studio. So hopefully that won't prevent you from following along no matter what. Now there will be other courses on Microsoft Virtual Academy that will demonstrate the power of visual studio proper. All the features that visual studio has to offer how you can improve your workflow with visual studio videos that explain the differences between the various versions and additions. But I'm not going to focus on that in this course. I'm going to focus specifically on the basics of the visual basic programming language itself. And what I want to demonstrate will be true no matter which version or addition of visual basic that you choose to use. And that's great news because as long as there's a visual basic, these lessons should still be valid and useful no matter what. Now to get the best or the most out of this or any course that you'll find online, you should become what I call an active learner. That takes several different forms. First of all, you should attempt to follow along as closely as possible and do what I'm doing in the video inside your own copy of visual studio.  You're writing it, I'm writing it, we're working together to actually work through these lessons. There's no better way to learn to code than to actually write the code yourself, not just watch the video on screen. It's like suggesting that somebody learned how to play guitar, but only by watching videos, not by actually holding a guitar in their own hands and strumming the chords. And if I were to say, well, here I'm going to teach you guitar, but don't touch the guitar, you say, well, that's virtually impossible. The same is true with code to some extent. You want to build muscle memory by typing in the code on your own. Typing in the code yourself will give you insights that merely watching the video will not give you. So do this, pause the video, rewind the video, rewatch portions of the videos if you need to. I'm going to make the code available that I type in. You'll be able to download it from wherever you're currently streaming this video on Microsoft, Microsoft Virtual Academy. And you should only use that to compare the code that I wrote versus the code that you wrote, not to just open the code up and run it and see what I wrote. Write it yourself. That's important. You should be typing everything in your own copy of Visual Studio, running on your own local desktop or laptop. Also, don't feel compelled to rush through this course. If something doesn't make sense, again, pause the video, rewind the video, rewatch those portions that don't make sense at first because after rewatching them and seeing the nuances or understanding, hearing me more completely might help unlock things in your mind. Sometimes a second or third viewing, focusing specifically on what's going around the screen in all the corners of the screen and on the words that I'm actually saying can help a lot. So being an active learner also means that you're taking control of the learning process. So if I say something or do something that really doesn't make sense, then by all means, find a second or a third resource online that can help you out. Maybe it's an article out on msdn.microsoft.com or maybe it's other videos on Channel 9 or Microsoft Virtual Academy, but life has more than one teacher. So if something I say doesn't make complete sense to you and you need to hear it from somebody else by all means, find some additional resources that can help you. Make sure you search out those resources that resonate well for you personally. If you're interested in a more comprehensive version of this course, except for the C-Shar programming language, well, that's something that I can help you out with on my own website, devu.com at www.devu.com. I have a course that spans 30 hours that has coding challenges, 30 hours of video instruction, also quizzes and cheat sheets and a lot more. So please visit me at devu.com. You're also going to find many other interesting training courses on my website that I've created specifically to help you become a professional software developer someday. So if that's what your goal is, then maybe I can help. And then furthermore, over time as we go through this course and as I begin to field some questions about it online, I might add some additional study resources and additional free content available for you here on this website. So make sure that you visit frequently. And like I said earlier, if you're new to programming, this is a resource that can help you out. I'm really excited for you if you are just getting started. Learning to write applications is one of my life's passions.  And Visual Basic holds a special place in my heart. I learned the basic programming language when I was 12 years old. That's like 34 years ago. And I did it on my very first computer, Commodore 64. Then after college, I found Visual Basic and I realized that I already knew the language part and the visual part was really easy to pick up. It was one of the first applications of its kind that allowed you to visually design forms on screen by dragging and dropping components from a toolbox onto a form designer. Now the basic language is actually an acronym for, as you can see here on Wikipedia, Beginners All Purpose Symbolic Instruction Code. It's a more human readable programming language than other programming languages, but that readability, that human readability comes at a price. It's a little bit more verbose, meaning that you have to use more keystrokes to build your code instructions. Some other programming languages like C-sharp require that you type in less instructions to accomplish the same thing. And primarily for this reason, some professional software developers prefer other languages like C-sharp over Visual Basic. However, there's virtually no difference between applications that are created using C-sharp and applications that are created using Visual Basic because they both end up creating a .NET assembly whenever you compile your source code that you wrote into an executable. Or rather, a .NET assembly. Now I'll explain the technical details around that a little bit later in this course, but if you're just learning to code, in my opinion, go ahead, use whatever tool that helps you understand the concepts and helps you get your feet wet in software development. Later on, you can graduate to other languages because frankly, many of the concepts that you learn in Visual Basic, they're going to transfer almost directly over to C-sharp. And there's very little that you'll have to learn additionally in order to make that transition. It'll just be shortened forms of some things, okay? So when you're getting started, you're embarking on a really exciting journey that's immersive and it's personally and professionally rewarding. And best of all, I know you can do this. Again, I've seen so many people start off where you are right now assuming that you're just getting started. And they've worked through the lessons and they've worked nights and weekends to teach themselves how to code. And now they're working professionally writing code for a living or building real applications that are being sold in apps like in app stores like the Windows Store. So if you've ever gotten stuck in the past trying to learn how to program, I promise that if you put the time in and you put the effort in and you work along with me, as you and I work together, we're going to build your knowledge of Visual Basic and you'll be well equipped to take on more advanced tutorials after this course. You can even learn how to build web applications and Windows applications, Windows Store applications so apps that can be sold in the Windows Store. You can learn how to create cloud services and video games and even applications that run on iOS and Android all using simply Visual Basic. So again, assuming that you have some version and addition of Visual Studio already installed on your local computer and you're ready to go, then we're going to begin in the very next lesson, Writing Visual Basic. And I hope you're excited because hopefully you can tell I am. I'm really excited to get started.  So let's go ahead and get started together and I'll see you there in that next lesson. Thank you. Let's take a look at how to install Visual Studio using the custom option. For this example, we'll use the Community Edition of Visual Studio 2015. In order to get it, simply visit visualstudio.com and click on the Download Community 2015 button. Once we've clicked on the download, it'll download to our computer and it's a web installer. So we click on the Run button and it will initiate the installation routine for Visual Studio Community 2015. Once we have the options screen available, it's time to start looking at customizing the installation of Visual Studio. For the most part, the default allows you to create web and desktop type applications. But if you want to create different styles of applications or include more languages, then the custom option is what you should be choosing. I always recommend selecting the custom option for the installation of Visual Studio 2015 to ensure that you're getting the packages and libraries that you need to create the applications you may wish to use. So by selecting Custom and clicking on the Next button, we are now brought to the screen where we can select the different features. The first option is Programming Languages. And if we click the arrow to expand it, we can see that we have Visual C++, Visual F-sharp, and the Python tools for Visual Studio that are additional programming languages that will get installed if you select this option. Remember, by default, Visual Studio Community Edition will only install C-sharp in Visual Basic Templates. Also notice under Visual C++, we have options for the common tools, the Microsoft Foundation classes, and then Windows XP support for C++. For my purposes, I like to have all of my programming languages available to me because they create projects using the different languages all the time. So I'm going to select the checkbox next to Programming Languages to install all of those programming types. Also, under Windows and Web Development, we can choose various options here for things such as the Quick Ones Publishing Tools, SQL Server Data Tools, PowerShell Tools for Visual Studio, Silverlight Development, etc. Here's a very important component. If you want to develop universal Windows applications, we need to ensure that we have the tools, the emulators, and the SDK. Now, you can choose the default install of Visual Studio and then come back and install the Windows 10 SDK at a later time, and that will include the tools, the SDKs, and emulators for you, but it's so much easier to install these during the installation of Visual Studio. Please note that it will increase the install size of the application, so the tool set will be much larger. So again, depending on what it is that you want to do, you may want to select the Universal Windows App Development Toolkit, PowerShell tool for Windows, or for Visual Studio rather, if you want to be using PowerShell tools within your applications. If you need backward compatibility for Windows 8.1 and Windows Phone 8.0 and 8.1, you can select this option. Also, there are some common tools or cross-platform mobile development tools. These are important if you want to develop applications using the Xamarin platform. Xamarin is a cross-platform tool that allows you to create applications for Windows Phone, for iOS devices, and for Android devices by using the C-Sharp language in Visual Studio. All of these tools are available for the cross-platform mobile development using Xamarin platform. It includes all of the emulators as well, so again, remember, it will increase the size of the install base for Visual Studio. You might also notice that because I selected the cross-platform mobile development tools, we now have a little box inside the Windows 8.1 and Windows Phone tools. If we expand that, we'll see that it has included tools and Windows SDKs. And the reason it does that is because there's a potential that you may want to target Windows Phone 8.0 or 8.1 applications, so the tools and SDKs will also get installed. At the same time, the common tools checkbox includes a little square box indicating that we have also added another component here, and that is the git for Windows. So we can install git, which is your source control, git hub extension for Visual Studio so that you can integrate with git hub source control projects, and then of course an extensibility tool to update three for Visual Studio as well. You'll notice that by selecting all of these options, setup can require up to 48 gigabytes across all of the drives that we'll install it on. So again, review each of the items that you have selected to ensure you have all the necessary components, tools, and SDKs for your development tools of choice or platforms of choice, and then select the next button. Once you do, you basically see a quick little selected features screen that will tell you all of the different items that you have selected, and by clicking install you'll agree to the license terms of all the software components. If you're not sure what those are, each one of the items that has license terms allows you to click on it to view those. Once you're satisfied with it, click the install button, and Visual Studio starts installing all of the components that you have selected. So this is a quick overview of how to perform a custom installation of Visual Studio 2015. Hi, I'm Bob Taber with Developer University. For more of my training videos for beginners, please visit me at devu.com. In this lesson I want to show you how to build a super simple visual basic application, a Hello World application. It'll simply display the message Hello World in a console window on your computer. Now, I'm not going to attempt to even explain why I'm doing what I'm doing. The focus will purely be on what and how I'm doing it. In other words, I want you to focus on the workflow at this first pass. How to create a new project? Where do you type your visual basic code? How do you test your application and actually see it running as you're building the application? What do you do if you actually mistype code? How do you fix the problems that pop up? And how do you save your project to disk? And things like that. And so for now, just try to follow along and do exactly what I'm doing. Don't worry if something doesn't really make sense just yet. That's really what the rest of this course is for. We'll get to it. I promise we'll explain everything. In the next few lessons, we're going to dissect this tiny little application that we're going to build here. And I'll explain at that point why we did what we did, the purpose behind everything. Again, like I said in the introduction to this course, I'm going to assume that you have some version and addition to Visual Studio already installed. Even if your Visual Studio looks a little bit different than what you see on my screen, that's okay. The basics are the basics no matter what. So let's go ahead and get started. And I'm going to go to the File menu and select File, New Project. That'll pop open the New Project dialog. And this is important. If you get lost on this step, you're going to be lost, significantly lost. So take a moment and really pay attention to what you're doing here. Make sure you're in the installed templates here on the left-hand side. You're going to see a number of languages and tools over here now beneath the word templates. You must make sure that you have selected Visual Basic. If not, you're going to wind up with a weird template and you're not going to know what to do next. I've gotten enough comments through the years to know that this is a frequent mistake that people make. So make sure that you select Visual Basic and then you'll see a list of template types. And we'll talk about what templates are a little bit later in this course. But for now, we just want to make sure to select Console Application. We're going to use the Console Application template pretty much exclusively throughout this entire course until we get to the very end. And so you'll always want to make sure to choose Console Application. The next thing we're going to do is give our new application a name. When we change the name, there will be some changes to the solution name here below it. And so I'm going to type in the word Hello. Capital H, Hello. Capital W, World. Notice that I didn't put any spaces between the words Hello and World. And then you'll see that that same word is typed here. I'll show you what that means a little bit later on. By default, it's going to put your new projects into your Documents folder. And so for me, my user on this computer is Bob. And Bob has a Documents folder. You're probably familiar with that. And inside of there, there will be a Visual Studio folder with the year or rather the version of Visual Studio that you're currently using. In my case, 2015, it could be 2050. I don't know. Whenever you're watching this course. And then finally, there's a subfolder called Projects. And that's where we want to start off by saving all of our projects. You could change this and put this someplace else. But if you keep it here, then you always know where to find your projects. Now, if there's any other selections to be made here, and it might depend based on which edition of a version of Visual Studio that you're actually using, just make sure that if there's an option to create a directory for the solution, make sure that that is turned on. But everything else can be turned off. You can ignore every other little message that pops up or click the OK button to create our new project. Visual Studio goes off and does some work for a moment or two. And ideally, you have this little window in the upper right hand corner called the Solution Explorer Visible. This is going to show you all the files and things that are associated with the project. We'll come back and talk about that later. Here in the main area, you'll see a tabbed area called Module 1.VB, hopefully opened up. And inside here, we're going to make some room for ourselves. We're going to put the little carrot there on line four. I'll hit the Enter key on the keyboard a couple of times just to make some space for what comes next. We're going to type in some code. I'm going to type in the word Console because I want to work with a console window. And I'm going to hit the period key on the keyboard. And I want to write a line of information to the screen. So I'm going to use this write line method. We'll talk about methods in just a little while. Write line. And I'm going to give it the message that I want to be typed in. So I'm going to use double quotation marks. And I'm going to type the word Hello, Space, World. Whatever I type inside of these two double quotes, this will actually be displayed to screen. We'll come back to that in just a moment. And then I want to make sure to write one more line of code, console. And you'll see little windows pop up with information and messages that can be distracting at first. But actually, this all comes together and it becomes one of the most useful features of Visual Studio. So ignore it for now. We'll pay attention to what it is a little bit later. Just type all the way through what I'm telling you to type right now. Read line. And then we're going to use an opening and closing parentheses, but nothing inside of it this time. Okay. So the next thing we want to do is save our work. And I'm going to hit the little icon on the toolbar. Save all. It has two little disks next to each other. And you'll see the little yellow line here turns into a green line, letting us know that everything's been saved. And then you should be able to find a little green arrow with the word Start next to it here on your toolbar. Now, sometimes you may not see these based on some of the default settings, or you may have accidentally moved some things around. Just about everything you see on the toolbar can also be found in the menus. So for example, in the file menu, there's a save all option. And then in the debug menu, there's a start debugging. So if there's something that you don't see on your toolbar that you see on mine, just look through the menus and you might find it there. But ideally, it would be here on your toolbar. I'm going to click the Start button. And you'll notice that the appearance of Visual Studio changes a little bit.  Awesome. All right, so we built our first application. How do we stop the application? There's two ways. I could click the little X button here in the upper right-hand corner, or I can hit the Enter key on the keyboard. The application will stop executing and now we're back into edit mode in Visual Studio. Back here in the code where we could modify it and make changes. So you can see that Visual Studio is now returned to its original state. And you might see some other windows pop open from time to time. You can safely ignore those for now. Now, what if your experience was vastly different from my experience? So for example, what if you type the code out but you see an error message pop up when you actually attempted to run the application or start the application? You get this little error message that says there were build errors. Would you like to continue and run the last successful build? Select No. And then what you should see is a list of errors pop up. A list of errors here in a little window called the error list. And in this particular case, you can see that I get a little notification of the issues. And if I were to click on one of them, it would take me to the line of code where that error was actually manifested. Now, the error list popped away, but if I hover my or click on the error list here in the bottom, it will pop back up for me. So it goes away, it pops up. All right, so you can feel comfortable with moving around Visual Studio to that extent. Also, if I hover my mouse cursor over this little red squiggly line, it will say that there is a declaration expected. The reason for this particular error is because you wrote the code in the wrong place. You may have placed it between the module and end module keywords, but not between the sub and sub. Again, ideally this code belongs right here between the sub main and the end sub. You need to put it right there in the middle. And so that's probably one of the first and most important messages is that it matters where you type your code. And I'll explain what a sub is versus a module. There are other kinds of code blocks as we'll come to understand as we continue through this series. But that's one potential error that you could have run into. You saw how Visual Studio tries to tell us that there's a problem with the red squiggly line. It also gave us a list of errors. Now, once we fix those errors, notice that the error list is clean. So you can see also that it tells us that there's zero errors with our code. Awesome. Alright, so maybe you had a different problem. Maybe you see an error that looks something like this and you get a red line completely underneath it. You try to run the application. You get that same little there were build errors message in a message box. You click the no button and you see something like redine. Notice there's no well and redline is not a member of console. Now, admittedly, since we don't know visual basic very well at this point, the messages are not as helpful. But the fact that the error is happening on this line means that we can take a moment and really, really try to investigate what the problem is. And in this case, if you really look at it carefully, you'll notice that I'm missing the L in redline. So precision is extremely important as you're typing code. You have to type exactly what I type in order to get the results that I get.  So in this case, we just have to add the L in redline and we're good to go again. You can experience something similar if we misspelled the word console. In this case, you'll see that Connell is not declared. It might be inaccessible due to protection level. Now here again, the problem is we misspelled the word console. But once we fix it, then the error will go away and we can run our application again. Or perhaps you didn't use double quotation marks. And you see that Hello World has no double quotation marks around it. And you get two different error messages whenever you attempt to run the application. One says something about a comma. The other one says hello is not declared. It might be inaccessible. Or not as familiar with Visual Basic. At this point, the messages might throw us for a little bit of a confusing loop. But the remedy is easy. Again, precision is important. We have to surround that message in this case with double quotation marks. And I'll explain why in an upcoming lesson. What that really is telling Visual Basic, the Visual Basic compiler. But that's how we would fix that issue. So again, I think that making sure that you follow my instructions carefully, making sure you type the code where I type it, not outside of one of the code areas like I've designated. Like I've tried to call your attention to, but rather in the right spot. And then making sure you spell everything correctly. That is the key to moving forward whenever you run into issues. It's probably not Visual Basic or you have a problem with Visual Studio. Some people will say is my version of Visual Studio different than yours because I typed this out and it won't run for me. And invariably what happens is they've done something incorrectly when they typed in the code. So typing in code is an exercise in precision. You've got to make sure that it's exactly what you see on your screen and what you see on my screen is identical, okay? All right, so assuming you've got this to work, then you're well on your way to building applications. You've already learned some of the most important lessons so far, whether you realize it or not. As you undoubtedly learned in this lesson, writing Visual Basic code is an exercise in preciseness. However, frankly, Visual Basic is probably the most forgiving of programming languages because it will always nudge you in the right direction, at least as often as it can. Or at the very least, it's going to show you where the problem was by putting a little red squiggly line or something along those lines, giving you errors in the error list that you can work from. So in the following lessons, we're going to begin focusing on two things primarily. First of all, why we did what we did here. What happens whenever we create a new project? What happens when we click the Save All button? What happens whenever we click that Start button to actually run our application? So that's number one. Number two, we're going to focus on the syntax of the Visual Basic code that we wrote. So if preciseness is required, then you're going to need to have some explanation as to what all the words and the symbols that we've been using here, the use of the period, the use of the opening and closing parentheses, the use of the double quotation marks. What do all these mean? And honestly, it's really easy once you get started. Once you get a few basics under your belt, I think you're going to see that writing Visual Basic is almost as easy as writing English into Microsoft Word. Okay, so anyway, we'll see you in the next lesson. Thank you. Hi, I'm Bob Tabor with Developer University. For more of my training videos for beginners, please visit me at devview.com. In this lesson, we want to start with the process of dissecting this tiny little application that we created. Previously, I wanted you to focus on the workflow, what we did and how we did it. Now, I want to focus on why we did what we did. It's crucial that we cement these ideas in your mind because they really provide the basis, the foundation for everything else that comes next after this. So what I want to do is start on the inside and work our way out. And whenever you learn how to write applications with Visual Basic, learning the syntax of Visual Basic, or in other words, learning the nouns and the verbs and the punctuation of the programming language, is really just half of the battle. The other half of the battle is learning about related pre-built functionality that's available to the programming language. So in our case, Microsoft has created something called the .NET Framework. And while that sounds a little mysterious, it's actually not all that bad. For now, there's really just two parts of the .NET Framework that really concern us. First, there's a class library, which is simply a library of code that Microsoft wrote to take care of difficult tasks so that we as developers actually who will utilize or borrow from that library, we don't have to build that code ourselves. We can just rely or borrow that code from Microsoft. So there's this library of code to help with things like math operations or working with text or displaying things to the computer screen or transmitting information over the internet and a ton of other stuff. So that's the first part, the class library, which is part of the .NET Framework. The second part is called the .NET Framework runtime. It's also known as the common language runtime or the CLR. So the CLR, the runtime, is just this protective bubble that your application when it's running lives inside of. And I use the term protective bubble because the CLR, the runtime, it takes care of all the low-level details so that you, the developer, can focus on what the application does and less about interacting with the computer's operating system, with its memory, with its hardware, and so on. And furthermore, the CLR provides this layer of protection to the end user so that you, the malicious evil software developer, you can't really hurt the end user's computer, at least not without them asking permission if you can delete their whole hard drive, okay? So they'll have some knowledge or some ability to say, no, I don't want to delete the entire hard drive. So for right now, it's really the .NET Framework class library. The first thing we talked about that I want to focus on because we're writing code. So whenever we typed in this phrase, console.writeline, we were using some code in the class library that knows how to display text in a Windows command line window. And then all we have to do as the programmers is actually say what it is that we want displayed to the end user. And so we're just focusing on the important part. These are the words we want written out to the screen. Everything else, how is actually written out to screen? Well, that's the part that Microsoft takes care of for us because they wrote a library of code that we're able to borrow or use. So this next line of code is also important. Here we're telling our application to wait for input before continuing to execute. So here again, we're calling a method inside of the .NET Framework class library that expects input from the end user. We don't have to actually go through the hard work of listening for keyboard strokes and worrying about the signal as it's passed through the operating system and worrying about the hardware of the keyboard. All of that is abstracted away from us. All we got to do is say we want to wait for the user to actually do something on the keyboard before we continue on. So what happens if I were to actually say let's ignore this line of code? And to do that, what I'm going to do is add a code comment, and I can use a single quote mark in Visual Basic as a way to comment out a line of code.  We're essentially deleting it, but we're leaving it in the source code. I could have just deleted this out completely, so I'm going to select it all with my keyboard by hitting the arrow keys. I use the arrow keys a lot. You'll want to use those as well as the home and the end key so I can jump to the beginning of the line and the end of the line for any line of code. And I can also use the arrow key to move back and forth inside of the code. So here I'm going to hit the home key and then hold down the shift key and then hit the end key to make a complete selection. And then I can hit control X on my keyboard just like I do in any Windows application to actually delete that line of code. And yeah, I could have done that. However, now it's gone and I can't ever add it back in. I'd have to retype it. So commenting out the line of code is the preferred way to actually do an experiment without deleting your code completely, but you're saying ignore this line of code whenever you're actually running my application. So now what happens if we were to run the application but we left out that console.readline? Let's go ahead and run the application by clicking the start button. And it executed in a fraction of a second and then it ended. All right, so without pausing the application saying we need to wait for an end user to hit the enter key on the keyboard, the application executes and it's finished in a fraction of a second. All right, it flashed on screen and then went away. And so that's why we need both of these lines of code in order for our application to work the way that we had expected. Okay, so let's talk about the position of the code. You'll recall that I made sure in that previous video to emphasize that you have to put the code in the right place in order to get the same results that I got on my screen. So the right place was between this sub main statement and this end sub statement. All right, so together these define a block of code. And you can see when I even put my mouse cursor on this line that it will highlight the corresponding end sub. So here's the beginning sub and the end sub. Furthermore, I can hover my mouse cursor off to the left-hand side with this little minus and notice that it will highlight in a very, very light gray color the entire section saying that this all belongs together as one block of code. Furthermore, I can go ahead and click that little minus sign and it will roll the code up. And you'll notice that now we're going from line 1, 2, 3 and then we jump down to 10. Where did 4 through 9 go? They're actually rolled up together in this little section and I can hover my mouse cursor over and we can see the full definition for that sub main in a little window that pops up underneath our mouse cursor. But essentially what we're saying here is that this code all belongs together in a single code block and this code block has a name. We've given it a name called main. And once it has a name, we can call it by its name. So before we get to that, let's talk about this other level of indentation that we have here. An outermost module and as I hover my mouse cursor or I put my mouse cursor on the module, notice that it corresponds here down at the bottom with this end module word. So you can think of when you write code as a series of containers. Here we have a container for our code and then it sits inside of another container for our code. So I'm going to oversimplify it for just a moment and build on this definition but basically this innermost code block here is known as a subroutine or basically just a sub. It's actually known by many names and the context of how we're using it will determine what we call it. So in this case just a sub or a subroutine. In other words, it's just a block of code that has a name and we can call it by its name. We'll come back to that in a moment. In other situations we might see it called function. And notice when I change the word function here it changed the word function down there. Now we do get a little squiggly line here because it's not really being used the way that it was intended to be used. We'll come back to that later. Let me go ahead and type the word sub here again and notice that it automatically changes it to end sub for me again. In other situations it's not known as a sub or a function but rather just in general terms as a method. And so I'm actually going to use that term method many times whenever I'm referring to either a sub or a function. And so we'll talk about what methods are. They have a very specific meaning but for right now I'm just going to use it in a very general sense that this is a method and the method has a name. The name of that code block is called main. This specific sub routine, the specific method it actually has a special purpose in our system. Since its name is main it just so happens that this code will execute first whenever our application runs. So whenever the application comes to life the application will look for an entry point. What do I do first? And whatever is defined inside of this method called main will be the first code that actually gets executed. From here then we would actually call other sub routines or functions methods in order to accomplish things in our application. We'll see examples of that as we continue on in this course. So later on you're going to come to realize that a method, in this case just a sub, a method means so much more but I just want to use that simple working definition of it being a code block that has a name and since it has a name we can call it by its name to execute that block of code. So whenever you have a name you can call something by its name whether it be a method or a module or a class and so on. We'll talk about all these ideas a little bit later in more detail. So the main method lives inside of this module, a module simply known as module one, the default name. And so a module is simply a way to, simply an organizational tool. It's a way for us to keep all of the methods, the sub routines, the functions, that kind of are related together in some way that are similar in nature. So you put all of the methods that are somehow related into a single module. There will be another container for your methods that we'll talk about later that's called a class. So a module is kind of like a class but a class has a slightly more advanced and very important usage in Visual Basic. But in both cases, whether we're talking about modules or classes, you're going to put all the methods that are somehow related together inside of that same kind of organizational unit, that Tupperware container as I sometimes call it. So what do I mean by related together? Well, that's really up for you as the programmer to decide based on the type of application that you're building. You're going to come to understand as we go further through this and as you continue on past this course, the philosophies of writing code that will dictate where the code should reside inside of your application. So the module is pretty simple and is pretty straightforward and that's why we're starting with it here. And the class is a little bit more advanced but ultimately they're kind of the same. In fact, the class actually is more than just an organizational tool. I really oversimplified it like I oversimplified the notion of methods but I want to keep it simple for now. Let's just use that as a working definition until we get a couple of lessons from now when we'll start creating classes of our own and we'll talk about why classes are so important. But the main takeaway now is that code is organized inside of code blocks and you define a code block by using a keyword like sub or function and then end sub or end function or another type called a module and end module eventually will create class and class. Those define code blocks and code blocks can live inside of other code blocks as an organizational unit. All right, so let's take a look at this line of code again here in line number five as you see on my screen. Here we're actually executing a method we said before that this is from a library that Microsoft created and that's true but we're actually executing a specific method by using its name, right line. And so now anything that was defined inside of the right line method by somebody at Microsoft will get executed when we call the name of that method. So it actually lives inside of a class, a container called console. And so the second line of code that we wrote also is from the console class but it calls a different method called read line. So read line is calling a different block of code that somebody at Microsoft actually wrote and we've already talked about the purpose of right line versus read line. Why are they both associated with this console class? Well, they're organized into the same class, the console class because they both have something to do with building applications that display as console windows on our computer. So they're related in a sense in that way. If I wanted to do something with the windows console what would I do? I'd go to the console class and then call one of its related methods, okay. And the way that I do that is by accessing the methods of class using this little dot operator, all right, the period on our keyboard. So here we're able to say essentially module one dot main except in our case we're saying console dot right line or console dot read line. So this little period is actually known as a member accessor. In other words, we can access a member of the console class by using a period and then after the period, the name of the class, the period, then we can look at all the members of that class, the members being the various methods and other things that were defined inside of the console class, all right. And then we can actually type the name of the member in this case, the right line member method versus the read line member or method in order to execute it, all right. Now notice that immediately following both the right line and the read line that in both cases we have a pair of parentheses. Now, admittedly in this first case we're actually putting something inside of the parentheses in the second case we're not putting anything inside of the parentheses. In the case of the read line here in line number six, really all we want to do is just say go ahead and wait for input from the user. So we're using an opening and closing parentheses because we don't have any extra information to say to tell that library of code that Microsoft wrote. We're just saying wait. Here, however, we need to give some additional instructions. We need to say what we want right line to print to the console window. So to do that, we're going to give it the words we want it to print a screen. And whenever we're going to give it words we need to treat them as a literal string of individual characters. So I want you to write the letter H, the letter E, the letter L, the letter O, and so on and use a space. So I want this exact string of individual characters. So we're going to call this a string, a literally this string of character, so a literal string of characters to the console window. And so we're going to talk about strings versus other types of information, maybe numbers, maybe true, false, maybe dates and times. So we'll talk about data types in Visual Basic in another lesson, but it's pretty crucial to understanding Visual Basic. But here we're going to give it a literal string of characters we want printed out to screen. All right, but the key idea here is that some of these methods can accept input as parameters, so we'll call them input parameters, and some of them don't require any input parameters in order to do their jobs, all right? So we're going to come back to the notion of methods in the future and how to pass data into methods, just like we did here with Hello World in line number five and the significance of the double quotes, but just know that whenever you see a set of parentheses after a word, the method is being invoked. So the parentheses are actually a special tool inside of Visual Basic called a method invocation operator. We want to invoke the method. We want to say, do it, run, go, do your job, and here we'll provide you some extra information and the form of an input parameter, okay? So that's the purpose of the opening and close parentheses. So Visual Basic is really lax about some things and is pretty strict about some other things. In some programming languages, you could stretch a single line of code onto multiple lines because the line of code is so long that it might run off the visible area here inside of your code window. And now in some cases, like in C sharp, you can do that automatically. You don't have to do anything special. However, in Visual Basic, it's not the default behavior.  In Visual Basic, by default, a single line represents a single idea, a single thought. It's like a sentence in the English language. And to separate these onto two separate lines, you're essentially creating two sentences without using the correct punctuation, all right, if that's the right analogy, okay? But you can actually do this if I had a really long line of code and I needed to separate it so I don't have to scroll off to the right-hand side of the screen every time that I wanted to read my code. I can use what's called a line continuation character in Visual Basic. So it's simply an underscore. So in this case, I'm able to say console and then hang on a second, let me use an underscore, write line, okay? And I might use some indentation here just to make it obvious that these two kind of belong together, all right? But that's not necessary. So in this case, this would be kind of silly to actually do this. So I'm gonna remove it, but you can use an underscore character and we will throughout this course to split up lines onto multiple lines to make it more readable so that it doesn't go off to the right-hand side of the screen. Additionally, I can kind of do the opposite where I can put multiple lines, multiple instructions on a single line. And so here again in Visual Basic, one line by default represents one instruction. And so we have two instructions in our program right now. But what if I wanted to combine them onto the same line of code? If I try to do that without anything, I would get some errors, right? Because there's really nothing separated and you would see the end of the statement was expected. And so if I really wanted to do this and there's really not much of a reason to, but you might see it in somebody else's code, you can use a colon. In that case, now we've ended one line of code here and we've said, okay, just let's pretend for a moment that this is actually a different physical line and then this other line of code and now the application will execute and run exactly the same as it did before. All right, there we go. I'm gonna go ahead and get rid of that too. Now, I want to also notice that by default that we get some indentation levels. Like here at this left-most indentation, we have the module. And then kind of to denote containment, there's another level of indentation for the sub-main. And then inside of the sub-main, again to indicate containment, there is the code that we actually wrote and then I showed you just a moment ago how I might use indentation another time to indicate some relationship. So if I wanted to do that, that might help me to see that these two lines in five and six are actually related together, they're physically separate lines, all right? So there is some indentation by default and the Visual Studio IDE, the code window that we're typing in will nudge you in that direction. Even if I tried to, for example, start typing a line of code here and do console.write line, that's all folks. And I hit enter on the keyboard. All right, it's not going to... Because I forced the issue, I made it line up there on the left-most column. It won't force it, but if I were to just hit the enter key on the keyboard, it's going to put it right there in line with all the other code. All right, so just be aware of that, that I might need to re-indent some code if I took extraordinary measures in order to move it off to the left-hand side. But indentation is completely optional in Visual Basic, it has no real bearing. Furthermore, white space has no real bearing in my program as well. So you can see I have all this extra white space. It doesn't mean anything. I could actually remove all of it just by kind of making some selections here on my keyboard and deleting. And this will work just as well as this works. So why do you suppose that we have the notion of indentation? Why do you suppose that I add and that the template added white space in between certain containers of code? Well, it makes it a little bit more readable, right? I mean, if you have it all scrunched up together or you have it way too far apart, or if all of the lines of code are butted up against the left-hand side, it's not visually as easy to tell where you're at in the hierarchy, so to speak, of the code structure. And so that's why Visual Studio automatically will try to nudge you in the right direction to format your code in this way. Now along the same lines, Visual Studio also color codes certain types of instructions that we type in. So for example, you can see here that this hello world is in this really by default. Your colors might be a little bit different than mine. It really doesn't matter. The fact is that Visual Studio will try to color some things differently. So by default, you can see here that there's this dark, deep red color. Which indicates that this is a literal string. Then there's this aqua color, which says that this is a class or a module. All right, there are things that have a more, a royal blue color. These are key words inside of Visual Studio, and you'll see some other colors pop up as well. Whenever we use the code comment, notice that the whole line turned green. That says it's a code comment. So different colors, just like indentation levels, just like white space, help the readability of our code. All right. So we've talked about the code that we wrote. Next up, let's talk about the file that we actually wrote our code into. This module one dot VB. I don't know if you saw that little tab name up in the upper left-hand corner. And we're going to talk about how code files relate to projects, and how projects relate to solutions, and what happened whenever we click the Save All button here on our toolbar. And then we'll talk about what actually happened when we ran our program then in the video after that. So there's some important concepts that you're going to learn about project management and about compilation in the next two videos. Make sure you watch them. We'll see you there. Thank you. And where they're stored on your hard drive, how to open up a project that you previously closed, how to open up one of the code files that I'll supply or that some friend might give you, that you can download in a zip file, how to unzip it, put it into a directory, open it up and so on. So whenever we created a new console project in one of the previous lessons, the module one dot VB file automatically opened up into this main area inside of Visual Studio. And that's one of the things that project templates do for us. They provide a great starting point for the type of application that we want to build, including files, boilerplate code. So it gave us this module, module one, sub, main, and sub, and module. Gives a boilerplate code. And then also it added some settings. We don't see them right here, but there are some settings that are stored here in this app config and in this hello world file that you see listed here in the solution explorer and some other resources, depending on the type of template that we choose, all right? So this little tab here at the top, and my version of Visual Studio, it's a dark blue tab. It really depends on the colors you have selected. And again, your version of Visual Studio might show it a little bit different than mine. But anyway, it indicates which file we're currently working on here inside of the main area. If we were to add an additional file to our project, there are a couple of different ways to do that. We would see we could open up multiple files here and have them all open at the same time, but only view one at a time. We'll look at some maybe window management accidentally as we go through this course and you'll see. But before, again, a more thorough explanation of how to utilize Visual Studio and get the most out of it, you'll want to watch an entire course just on the Visual Studio IDE itself, okay? But at any rate, that tab has a label inside of it and it indicates which file we're currently working on. So our Hello World program right now only has one code file, like I said a moment ago, but as our applications become more complex, we're going to organize our code into potentially many files inside of the same project. Now, if you take a look over here and I've already referenced it once, there's this window called the Solution Explorer that by default is kind of docked up in the upper right-hand corner of Visual Studio. And it basically has a tree-like representation, a tree-like view of the items in our project and how it's related to our solution. Now, as I said at the outset of this course, this is not intended to be a tour of Visual Studio. There are going to be other resources on Microsoft Virtual Academy that can help orient you to Visual Studio, but the Solution Explorer is the most important part of Visual Studio, in my humble opinion, next to the main area where we're actually going to type our code. Simply put, the Solution Explorer is our main navigational device to the other files and the settings that comprise our program. So as you can see here, we have a module 1.vb. If I were to close this tab in the main area by clicking the little X button off to the right-hand side and there's nothing now in the main area, I could open that file back up by just finding it here in the Solution Explorer and then double-clicking it and there you go. We're back into our module 1.vb. So files and important settings are organized into projects, which are then compiled into a single .NET assembly. We'll talk more about compilation and .NET assemblies a little bit later in another video. Furthermore, one or more projects are organized into solutions. So in many cases, as you're getting started, you're only going to have one project inside of one solution. But as you build more complex applications over time, it's highly likely that you're going to manage multiple projects that are somehow related inside of the same umbrella called a solution. Again, the reason for that might not be obvious today at this moment, but as you continue learning about Visual Basic beyond this course, I think you're going to find that as you build more complex business-oriented applications, this becomes a crucial code management strategy to put things in different projects depending on the functionality and the role of that code inside of the larger software system that you're building. Again, that's a topic for another day. Just for now, except that there's this extra layer called a solution that owns projects, one or more projects, and trust me, it becomes more important as we move past the basics. But for the most part in this course, we're going to only concern ourselves with talking about projects. This point should be, where are all of these files actually stored on my local hard drive? I can see them here in the solution explorer, but where are they on my local computer? So whenever we created the Hello World project and recall that we went to File New Project, that opened up the new project dialogue, and we typed in the name of the project that we wanted to create. And then I also called your attention to the fact that there's this location here and that this would be, by default, where our code is actually saved. So by default, it's going to put it in the current user's documents folder. So if you have multiple users on your system, then it's going to be whatever user you currently are logged in as. In my case, I only have one user on my computer, the Bob user, me. And Bob has a documents directory. And inside of that documents directory, there's a visual studio. And then, in my case, 2015, it could be 2016. It could be 2050 if you're watching this, what, 35 years from now?  So this is where, by default, things will actually be stored. If we take a look at Windows Explorer, so I'm sorry, the File Explorer here in Windows, and let me resize this a little bit. Mine's going to look dramatically different from yours and I'm going to use this quick access feature quite a bit. But suppose, for example, that we're looking at the desktop here, by default, and I've got a lot of junk on my desktop. Here, I'm going to be able to look at the documents directory. All right. Now, sometimes this documents directory will show all of the documents. And sometimes it shows just a subset of documents. This case is only showing a subset. I actually have quite a few more folders. But for our purposes, right now, this will do. You can see that there's this Visual Studio 2015 folder for my situation, for my case. Inside of that, then there are a couple of subdirectories. There's the Project subdirectory. Now, again, let's just ignore this version of this and go back to the quick access, where we're going to get to my documents directory. You'll see everything in documents. We'll go into Visual Studio 2015. Then we're going to go and we see quite a few more folders. We'll go into Projects and there we are. This is a low world folder, all right. And as I add more projects, they're going to fill up this Projects folder here. And it's important to note whenever you create a new project, you can put it anywhere on your hard drive that you want. I just usually accept the default, at least to begin with, unless I'm very purposeful in what I'm trying to accomplish. Maybe I want to put it someplace else because I want to work in a team environment and we're all agreeing to put our code in a specific place or use a tool that really kind of pushes us, nudges us towards a different file structure. Be that as it may, we'll come back to that idea some other day. All right. So furthermore, you can open up a project that's saved anywhere on your computer and to illustrate this, I wanted to give you, and I'm just going to shut down Visual Studio for now completely. I gave you this file. You should be able to find it wherever you're currently watching this video, wherever you originally downloaded the video from. There's also a file that should be available called example.zip, and it has a project inside of it. And so what I want to do is extract this to my hard drive. I'm just going to right-click here and select Extract All. Pops open the Extract Compress Zip Folders dialog. And I'm actually not going to extract it to my desktop. I'm going to extract it to the root of my C drive. And then I'm going to click the extract button, and it says, hey, there are actually some files with the same names. Unfortunately, this is due to the fact that I've gone through this example before. So let me do this. Let me cancel this out. Cancel this, cancel, cancel, cancel. Let's open this up. Let's delete. Let's find my local computer here. There we go. And I'm going to delete this folder. OK, so now you can see this is all the junk on my folder, and I have a very, very messy hard drive. I'm going to right-click the example again and click Extract All. And here we're going to go and just say, I want to extract this project called example to my C colon slash drive. Extract it, and there we go. So now if we were to open this up and double-click the example folder, you can view the contents inside of it. And you see inside of this another example folder and an example.sln file. So this second example folder actually contains the project. And this example.sln file is the solution file. This solution file is the same as the solution that we saw in the Solution Explorer. So a solution can contain one or more projects. And here the projects are going to be contained inside of subfolders. If we were to actually open up this .sln file, here I'm just going to open it with. And you can see I have the Notepad app already selected because I've made some changes in Windows. If you want to open it up with Notepad, you should choose another app. It'll give you this little dialog here, at least in Windows 8 and Windows 10. All right, so we're going to open with. And here you might see some options. Visual Studio is the preferred way to actually open up an .sln file. We don't want to change that. Therefore, if you do search through your list of apps and you're trying to look for Notepad, make sure you do not click this check box. Always use this app to open .sln files. You do not want to do that. You will hate me if you do that. So select Notepad, but don't check that check box and click OK. You can see that this solution file just simply has some settings related to versions and what's inside of a project, some global settings, some other information about configurations, and so on. We don't want to make any changes in this file whatsoever. So just carefully close this if it asks you to save any changes that you made. Make sure you do not save those changes. Otherwise, you're just going to need to delete it and start over again with a new zip file extracting it, OK? All right. So we've satisfied our curiosity, but what's inside of this project folder? Well, you can see that we have another file called example.vbproj. This is the project file, and here I'm going to do the same sort of thing where I'm going to open this with and I'm going to choose Notepad again, making sure not to select this, just to satisfy our curiosity. Here we see that this is an XML file that just has other settings related to this specific project, a lot of settings. We do not want to make any changes to this whatsoever. It just has information that's going to be used by the visual basic compiler to create an executable for our application and also maybe some other things related to how we want our project organized and what we want visible in our application. I'm just going to close that. We do not want to make any changes to it. There are also then some subfolders inside of it, the same project folder. I think the most important thing we see here is this module 1.vb file. So this is the code that I wrote for the example project. And if I wanted to open up and work on this project now, I have a couple of choices. I could either double click this example.vbproj from our file explorer, or I could double click the example.sln file to load it into Visual Studio. So just to show you that, that's usually how I open up the projects. Or the other thing that you can do is actually go to the File menu and select Open Project or Solution. Or if you've opened it recently, it might be in your list of recently opened projects and solutions and you can navigate and find, for example, the Hello World project and open that back up into the Solution Explorer.  Here I want to go into our documents, Visual Studio 2015, Projects, Hello World. Then I want to go to the Hello World project inside of the Solution folder and I want to look at this bin directory. So bin is short for binary. It denotes that there's a binary executable output that will be added to this folder whenever we go through the compilation process. Whenever we hit the Start button, it would actually create a debug version, compiled version of our application that can be run on our local desktop. So compiling your code into a working application is really the end goal of writing source code. But I want to stop short of talking about that in detail and pick up this idea much later in the course. I think you're going to get a better appreciation for it once we get past some of the basics. So I'm going to stop right now and I'm not going to show you what's inside of this debug folder. All I am going to do, though, is just talk about at a high level what we learned in this lesson related to the Solution Explorer, how it allows us to navigate through the code files associated with our project, how we're able to close down Visual Studio but then open up our project again either by navigating through the file system in the File Explorer or by using one of the open menus in the File menu so I can open a solution or project or open something that I've opened recently in the past in order to open it back up and continue working on code that I have in the past. We talked about the file structure and that you can save your projects and solutions anywhere on your hard drive, but by default it's going to put them in your current user's document slash Visual Studio slash project subdirectory so that it keeps them all nice and organized. I showed you how to extract out an example and put that somewhere on your hard drive so that you can then open it up into Visual Studio. So the source code that I give you and I make available with this course you can download it, extract it, and open it up and look at it in Visual Studio if you want to. So hopefully that all made sense and you understand those relationships. Now let's continue on and again we're going to focus on just that little hello world application but you can see how that's branched off into so many conversations now that are vital to our fundamental understanding of what's going on as we build applications in Visual Basic. We'll see you in the next video. Thank you. If you have any questions, please visit me at devu.com. In this lesson I want to get back into the Visual Basic syntax itself and I want to talk about declaring variables, choosing a data type for your variable and then initializing variables. So to begin with, as you can see in Notepad on screen I have a little algebra problem that I want to throw at you and even if you've taken an introduction to algebra you should be able to solve this one pretty easily, right? So here I just want to solve for the value of X. So without a whole lot of thought hopefully you can take a look and see that, well, the value of X must be seven, right? So using that same thought process now, take a look at this Visual Basic code.  Console.WriteLineY. What do you think will be displayed in the Console window when we execute this Visual Basic code? Well, probably the value 10, right? So you just read Visual Basic without any help from me. It's pretty common sense, right? I mean it, for the most part, makes sense what you're trying to accomplish once you understand, for example, Console.WriteLine. So, you know, first as far as Visual Basic is concerned, the X and the Y in this situation are referred to as variables. And so a variable is simply a bucket in your computer's memory that's capable of holding a value. So you can put stuff, you can put values into buckets or rather into variables. You can take stuff, values out of variables or the buckets, all right? And then suppose I put something in the bucket, I can put something else in the bucket and cover up or eliminate the original value and now it has something new in that bucket in the computer's memory, that variable, all right? So this particular case has these buckets just holding numeric values, but we could create buckets that are just the right size to hold any kind of data. So for example, we can create a bucket that's just the right size of variable in the computer's memory that's just the right size for strings of individual characters, so strings. Very big numbers, very small numbers, true, false, dates and times and numbers that have values after the decimal place and a lot more. So there's a lot of different kinds of data types that are available in Visual Basic. And so in the case of this little code snippet that you see on screen right now, we would expect that both X and Y to hold numeric values. Now these particular numeric values probably don't have any values after the decimal point, so that narrows down the kind of data or the data type that we would choose to store values for this particular application. Now we know that X and Y should store numeric values, but we have to express that intent using the Visual Basic programming language so that when our code is compiled it can be executed and carry out the instructions that we have in our mind. So the instructions that we give in Visual Basic will ultimately be executed by, remember that .NET runtime, what I call the common language runtime or just the CLR, and part of its responsibilities is to allocate space, buckets in the computer's memory sufficiently large enough to hold the variables that we declare, to hold data, and we tell it what kind of data, the size of the bucket in other words that we want to create in the computer's memory. So in this case we're going to have two data items, X and Y, and we have to tell the runtime using Visual Basic code to allocate some space, enough space in memory, sufficiently large enough to hold numeric data sufficient for our application. So how do we do that? Well, we do that by declaring variables. So let me go ahead and get rid of this and I'm going to create a new project. There's a number of different ways to create projects. We already did File New Project, right? But here on the start page there's also this little link that we can use, New Project. Either way it's going to pop open this New Project dialog. So what I'm going to do is call this project Variables, all right? And kind of the same rules apply that we talked about before, making sure that we don't make any other changes and just click the OK button. Now the big takeaway from this lesson is that a variable is simply a bucket in the computer's memory that you can store data inside of and then you can retrieve data out of it and that you have to create the right kind of variable using a data type. We have to say what kind of data, what data type we intend to store inside of that variable that we declare. So all the same rules apply here that we talked about in the very first lesson. First of all, you have to type the code in exactly the way that I type it in. If you don't, you're going to get some kind of error. Work through the errors, make sure you pay attention to detail. You know, if you have to pause the video, rewind it, look at the source code that I wrote because I'm going to supply that to you in zip files. You can unzip it, look at it, and compare what I wrote versus what you wrote. But by all means, write this code yourself and start building that muscle memory as you're typing code yourself. If you do run into problems, remember, Visual Studio doesn't leave you hanging. You'll see the little red squiggly lines. You'll see the list of errors as you attempt to start or run the application. Those will all give you hints and clues as to where to look for the problem and then just start developing that sense of being able to identify visually where the problems are in your code. You got to pay attention to the minutiae, spelling, punctuation, everything that, fortunately, individuals, people like you and I can understand even if it's not spelled correctly or punctuated correctly. Unfortunately, computers need things exact. And while Visual Basic is forgiving, as we said, you still have to give it the correct instructions. So what we want to do is write two lines of code where we're going to declare two variables. We're going to say create two buckets in the computer's memory that are sufficiently large enough to hold numeric values. And the way we do that here inside of our Submain is to use a dim and that is shortened for dimension or it's, we often call it declaring variables, okay? So we're going to give it a name. That is the name of our variable X. We can give it any name with some exceptions. We'll talk about that in a minute. Now we've got to say what kind of variable we want to create and we're going to create a data type called integer. We'll talk about that in a minute, too. So I'm going to do the same thing with Y as integer, all right? Now, to borrow from the explanation earlier in the lesson, we're officially asking the .NET runtime to allocate space in the computer's memory sufficiently large enough to hold two numeric values, one that we're going to label X so we can get back to it to save new values in it or to retrieve the values that are already inside of it and Y, another label for a different bucket, a different space in the computer's memory so they will hold two different values potentially, all right? So we're asking it to create these two buckets that will each hold values that eventually we're going to drop into those variables or drop into those buckets. And then after we've created those buckets or those variables, then we can begin to assign values into the variables and then retrieve values out of the variables, all right? So most importantly, we're going to assign integer values into those variables. How do I know that they're integer values? Well, again, here, we use the key word integer in lines number five and six. So integer is the visual basic term for a math, is a mathematical term really. It is, it refers to a number that has no fractions or values after a decimal place. It can contain very large numbers from 2 billion, 147 million and something odd numbers to a negative 2 billion, 147 million and something odd, okay? So if you need to store a number that's larger than 2 billion, 147 million, then you want to create a different bucket in the computer's memory because you're going to need a larger bucket to hold larger numbers. Conversely, you probably want to use a smaller bucket if you really don't plan on using very many values inside of it. So for example, a true-false value, you need a real tiny bucket because it only needs to store a zero or a one, which is true or false, okay? So anyway, like I indicated earlier, there are many different types of data types. There are simple data types, and then you'll also learn about complex data types. And then later on in this series of lessons, you're going to learn how to create your own custom data types using classes, all right? So because I don't want you to be overwhelmed just yet, I'm going to keep it simple for the moment. We're just going to talk about the integer data type. Here at the outset, we'll also talk about the string data type in this lesson a little bit later. All right, so first of all, I'm going to sign a value to X. I'm going to give it the value seven. Then I'm going to assign a value to Y. And we'll take whatever the value of X is and add three to it. Now what I want to do is write out the value, console.writeLine, the value of Y. And then, of course, we're going to use console.readLine so that we can actually see what it is that we typed in. Okay, let's run the application briefly. And we already know what the answer should be. The answer should be 10, right? Based on the little notepad equation that we saw earlier, we essentially just recreated this but using actual Visual Basic Code in order to come up with the value 10. So what really was going on here? Well, after we've created two buckets, two variables in the computer's memory, sufficiently large enough to hold integer values, then we started assigning values or putting values in those buckets and retrieving values out of the buckets. So in this first case, in line number 8, you can see that I am putting the value of 7 inside of the value in the bucket labeled X. Then I'm going to retrieve that value out of the bucket labeled X and say, what did I stick in there? Oh, yeah, the value 7. We're going to add those two values together and then assign that value to Y. So at this point now, Y should equal 10. Then we're just going to merely do what we've seen before and instead of hard coding the value of 10 as a literal string of two characters, 1 and 0, we're just going to give the console.writeLine our integer value of Y storing the value of 10 and it will figure out how to print that to screen and that's how we saw the number 10 show up in our console window. So I think one of the most important things that I didn't cover just yet is the role of this equal sign. It's actually an assignment operator. So in English, that line of code is basically saying set the integer named X equal to the value of 7. All right, and so we do the same thing in the next line of code. We're assigning this value into this variable. All right, so hopefully that makes sense. What I want to do now is comment out all these lines of code and I can just go through here and one by one use the little single quote mark in order to comment all of these lines out or tell you what, I'm going to show you a shortcut. There's a tool here on the toolbar that allow me to do the same thing. So I'm just going to select all the lines of code with my mouse and then I'm going to choose this little comment out the selected lines. Now, notice that I can also use this keyboard combination if I hit Ctrl K, Ctrl C, that's called a chord in Visual Studio when you do, it's like creating a chord on the piano and it will also comment all the lines out. But I'm just going to click the button here and you can see that it added a single tick mark to every line of code, thus commenting out the work that we've just done. I'll leave it here for your reference, all right. Now I'm going to create a few empty lines here by just hitting enter on the keyboard a couple of times and now let's create another example. Here what I'll do is we're going to go console.writeLine, open and closing, double quotes, what is your name? Question mark. On the next line we'll go console.write, notice I'm not going to use writeLine, we'll talk about the difference between the two here in a moment, console.write and then I'm going to use double quotes inside of that and say type your first name colon space inside of the double quote. The next line of code I'm going to create a bucket or rather a variable called lowercase my capital F and first capital N in name as string. Okay, so let's talk about what I did here. Instead of using just a single letter as my variable name, I'm able to use a very long variable name. Furthermore, I'm able to use lowercase letters and capitalize letters in order to kind of give me a visual cue of where one word ends and another word starts, all right. And this is called camel casing, we'll talk about in just a moment. And instead of creating an integer value this time I want to capture from the user their name. Their name is not going to be stored in a bucket that can hold integer values, right. We're going to need to store strings of characters so that it can store Bob, B-O-B, okay. So that's what my goal here is to retrieve the name of the user into this variable called my first name and the way that I'm going to do that is through the use of the read line. And so we're going to use the read line in a slightly different way than we had before. So my first name equals console.readline, okay. I'll explain what that does in just a moment. We'll make some more room. And then we're going to go console.writeline, open and close, double quotes, type your last name and here actually I don't want to do write line, I'm just going to do write. We'll go dim my capital L last, capital N name as string. My last name equals console.readline and then finally console.writeline and here this is going to look crazy. I'm going to do hello, comma. I'm going to use an ampersand character. My first name, another ampersand, that's under the seven key or over the seven key on your keyboard and now I'm going to use an opening and closing double quote. I'm going to put a space in between the two of them, all right. And this is just going to provide some spacing between the first name and the last name, like so. Okay, so let's go ahead and get started here at the very top of this and explain what this is going to do. First of all, what we're going to do is ask the person for the first name. When they type in their first name and hit the enter key on the keyboard, then we're going to retrieve that value and stick it into a variable called my first name. We'll do the same thing with last name by creating a different variable, reading off the value and putting it into the value of the variable. And then we're going to do console.writeLine and we're going to concatenate or append together my first name, my last name and this literal string, hello, comma, space using this ampersand character which is the string concatenation operator in Visual Basic. It just means that you'll just tie together all of these individual strings and we're using spaces here like in this case and in this case right here in order to give the correct spacing between the various words. All right, let's run the application and we'll go and walk through it and talk about what it does. All right, so here we go. What is your first name? Type your first name. Here, Bob, enter. What's your last name? Taber, enter. All right, now I unfortunately forgot something very important in my program. What did I forget? Whoops, I forgot the console.reline. So we can run it real quick again and I also want to put one space here between the colon and that closing double quote so that it keeps it consistent between the first name and the last name. Let's run it again. All right, and here we go. What's your first name? Bob, type your last name. Taber, hello, Bob Taber. Very cool, all right. So, great. First of all, let's talk about naming conventions and convention is basically something that most programmers do and they do it because it's not only a best practice but because all the other programmers are doing it too. And so it makes your code look consistent if you were to share your code with other people. So in this case, I named my variable my first name with starting off with a lowercase m and my than the capital F and first and capital N and name. And so this convention is called camel case and you should get into practice of using camel case whenever you name your variables because, again, most programmers do this, especially for variables that are declared inside of a given subroutine, function, or method. And we'll talk about the scope of variables in another lesson, but basically any variable that is of a local scope inside of a method, you should create them using this style of convention. You can name them anything you want. You should use long names and resist the urge to do what some books and some authors and articles that you might read online do, which is to use a convention like STR first name, all right. The reason people do this is to remind themselves that this is a string. If your methods or functions are so long that you can't remember or you can't see their declaration in one page of code, then your methods are trying to do too much, but that's a whole other topic. Typically, you don't need to use that. It just muddies up the readability of your code, all right. So furthermore, if you were to hover your mouse cursor over a given variable, you can see pretty easily what the data type of that given variable is. In this case, my last name is declared as a string. As you can see there, off to the right-hand side of the little bubble window that popped up underneath my mouse cursor. Okay, so the next thing that might have caught your attention is that we used right line versus right, here in lines 14 and 15. The only difference is that right line will create a brand new line for the entire statement, whereas right will echo the characters that you have as input parameters, but it won't move automatically to the very next line. It'll just stay on that line. So that's what allowed us to say type your first name, and then as we began typing, it came off to the right side of the colon that we had added right here, okay. So here we have requested now the actual name of the user and this is where we're using the console.reline in a slightly different way. We're retrieving whatever the user typed on the keyboard and when they hit the enter key on the keyboard, at that point, the read line method will have executed and take whatever values were typed in by the end user and then assign them to this variable. So we've seen console.reline used without retrieving values like so, but it has this second function where it will actually retrieve back the values if we're interested in those values that the end user types in and we are in this case. So we do basically the same thing here, nothing all that different until we get to line number 24 where we start appending values together into our right line in order to display them nicely to the end user to format that string nicely. Now there's two things that I want to point out about variables and about visual basic in general. First of all, visual basic is case insensitive. Now other programming languages like C sharp will allow you to create two different variables that have the same name but with different casing. So you could create, for example, my first name all lowercase and then create a second variable called my first name all uppercase and then create my first name with uppercase, lowercase, uppercase, lowercase and those will be three different variables. You can't do that in visual basic fortunately. It makes it easy to step on yourself and to make mistakes if you're not careful when doing that in C sharp. So you can't do that in visual basic. That means if I were to do this, my dim first name as string, you'll see that I get a red squilly line and it says the local variable my first name is already declared in the current code block. Why? Well, even though the casing on the F and the N is different, it is essentially the same as this declaration here in line number 16. So that's the first thing about visual basic is that it's case insensitive. Now when you type, sometimes visual basic will try to capitalize words for you automatically. So I'm not going to use the shift key at all as I type this. So dim and notice when I hit the space bar it made it from a lowercase d to a capital D. My other value as and I'm going to hit the space bar and it capitalized the word as and I'll hit integer and I'll hit the space bar and it capitalized the ion integer. So visual visual studio will capitalize words for you, but essentially that's that's a function of visual studio, not a visual basic. Now you'll also notice inherently that while it is case insensitive, you cannot declare the same variable twice. So that's the second thing that we noticed here a moment ago and that's why this would not work. My first name as string will give us an error because we've already declared my first name here and case does not matter. So you cannot declare the same variable twice like you can in other programming languages. Okay. So now that we understand how to declare a variable, let's declare it and initializes value in a single line of code. So here I'm going to comment out this line of code right there and I'm going to go to the next line. Dim my first name as string equals double quotes Bob. So when I use the term initialize, that means I'm going to set the value of a variable immediately at the point when I declare it. That's like creating the bucket and the value in the bucket all in one line of code. So typically what you want to do is give your variables values as soon as possible. This puts your variable into state, which will be an important idea as we learn about writing real applications as we get deeper into this series of lessons. But also experienced developers like to write less code and they're always looking for a convenient way to reduce the number of keystrokes and just the sheer amount of code that they have to read through. And so, you know, something as simple as at some point it's going to become simple to create new variables and to initialize their value instead of doing that in two lines of code, it just makes sense to put them all in one line of code. So what I want to do is actually now let's comment out this because that doesn't really make a lot of sense in this application to go ahead and initialize the value the way that we did here. But what I will do here in this little block of code is to kind of do it all in one shot on these two lines lines 22 and 23. Let's redo this so dim my last name as string equals console dot read line. So now we're able to do both of these things, not only create a new variable but also initialize this value to whatever the user types in on the read line. All right, so we talked about quite a bit in this lesson. We talked about what a variable is. Choosing the right data type based on the kind of data that we hope to store in memory. We talked about the difference between an integer and a string. So now we've got two data types to work with, right? Numeric values, especially ones that are between negative 2 billion and positive 2 billion that have no values after the decimal point or a string of individual characters. We looked at using the equals sign as a assignment operator for assigning and retrieving values. We looked at the arithmetic operator. I didn't really talk about it, but basically we were just going to use the plus sign in order to add values together just like we would do in an amath problem and we also looked at the ampersand which is the code, the string concatenation character in order to append two strings together. We looked at the difference between console dot write and console dot write line and we talked about naming conventions in camel case. We looked at some of the rules of visual basic regarding naming how visual basic is case insensitive, but it also will not allow us to create two variables with essentially the same name but just with different casing. So we've added quite a bit more information under our belt about visual basic syntax. Let's continue the ball. We've got it rolling now. Next lesson, thank you. Hi, I'm Bob Tabor with Developer University. For more of my training videos for beginners, please visit me at devu.com. In this lesson, things are going to get a little bit more interesting. Based on the user's input, we're going to write logic to execute either one block of code or a different block of code. When I use the term logic, basically I mean that we're going to make a decision to execute one block of code or another block of code based on some condition. For example, the user's input or maybe the state of the computer, the system itself that we're working in, or some other data that we have available to us. We're going to decide what to do with that input, with that data, and then react accordingly. What we're going to do is create a new project called Decisions. Again, visual basic console application. We're going to call this Decisions and click OK. I'm just going to start writing some code. Again, what you'll want to do is pause while I'm typing this and type it along with me and then I'll explain what it does. I'm willing to bet that you can figure out what this does even without my explanation because at this point things are so easy. Let's go ahead and just write it together and then we'll go on and talk about it. Here we go. There we go. I think probably most of this would make sense as you look at it on my screen. The one thing that might look new to you is the if statement that we have here in lines 10 and the end if in line 12. Notice that there's this level of indentation then creating a code block in between the if and end if statements. We've set up this condition if the user value is equal to one. So if the value that the user typed in when prompted is one then what we want to do is set this variable message equal to the string value you want a new car and then print that out to screen. So let's go ahead and run the application and just make sure it runs in this very simple case which I'm pretty sure well when I hit one on my keyboard and hit enter hey we want a new car. What I'm not accounted for are the other cases. So for example to nothing happens and the same would be true even if we typed in something like a bob and hit enter nothing happens alright. So first of all we want to talk about the evaluation operator. It is the equal sign so it's playing double duty. We can use it as an assignment to set the value of message equal to the value of some string like you want a new car but when it's used in the context of an if statement here we're going to do an evaluation is this true does user value equal the number one or the string value one alright. If it does then execute the block of code that's defined between the if and the end if if this is false so when I typed the number two or when I typed in the word bob then that's false and we do not execute the values inside of that code block okay. So that is what I meant by making decisions where we're building logic and executing that logic and then based on the input of the user will decide what to display or what code execute in a more general sense whether we execute this block of code inside of the if statement or not so again in this case this is using the equal sign as an assignment operator this is the evaluation or the quality operator okay. So what happens then if we want to try different combinations well I guess what we could do is then start a whole new if statement so if user value equals two then we can set the message equal to you one a new boat and I'm willing to bet that that would work but there's a more simplified version of this let's go ahead and just delete that because what we can do is inside that same if block we can create additional checks called else if statements alright so if the user value equals one is not true then we're not going to execute this block of code but what we will do is then move down to the next the next check and in this case else if user value equals two alright and if that's the case then we'll set the message equal to you one a new boat I could also do else if user value equals two message equals you one a new cat alright and then finally what if I none of these are true what if none of them are true and at this point then you know if we run the application and I type in the word Bob I get nothing alright well there's one of two ways I can handle that in this simple scenario I could assign the value of string to initially to bad input like so so it would none of these conditions would register and therefore it would just stay at its default value bad input and that would be printed to screen so here Bob that input but what I'd really like to illustrate for our purposes here just so you can see the last part of it if else if and if statement is just the simple else statement and in this case we're saying if this is not true and this is not true and this is not true then alright well this is the catch all otherwise just do this in this case we'll just set the message equal to bad input please try again alright or something like you lose or whatever the case might be and so whenever we run the application we type in Bob and hit enter bad input alright great I want you to notice something how I how I designed this code I could have in each of these cases just done console dot right line and then said you won a new car like so alright I would have had to add the console dot right line in each of these else of statements and in the else statement as well however what I chose to do instead was just to define a variable and have it store the message that I want displayed and then just call the console dot right line a single time here at the very bottom alright so that's just a way to simplify the code to structure the code in a very logical easy to maintain sort of way if I wanted to change how this message is displayed I might have to change it in several different places so for example I might want to change whoops let's do this and say result colon space and then display the message I would have to make a change to every one of these code blocks if I had written the value out but now I can just make a change in one place and just display then the message after it so just be cognizant of the fact that you can simplify your code and you can expand its functionality while reducing its the amount of maintenance that has to happen or add new functionality so I feel like I've accomplished that in this case by just kind of using this message variable to store the actual message and then only using console dot right line one time in my application so finally what I want to demonstrate to you is I'm going to comment all of this out and in some cases you don't need the if, else, if, else, and if you can use something just called the conditional method so there's a method called if with an I two I's, IIF and then an opening and closing curly brace it now in this first part what we want to do is set the expression so let me actually grab some code from earlier here and we'll grab these first three lines of code and I'm going to select them all and then use the button that's right next to the comment out the selected lines and this is the uncomment the selected lines and that will remove the little comments from each line of code alright so now we have the user value again and here what I want to do is if I if open and close parentheses user value equals the value of one then after that one I'm going to use comma you can see I can add a true part and a false part so here what I'll do is say the true part is car but for everything else if that's user value is not equal to one you just want a free cat alright so let me do this I'm going to go dim message as string equals empty string and then message equals if the user value is one then I'll give them a car but anything else they'll win a cat and then we'll do console dot right line the message and then finally console dot to stop the execution and now let's run the application and type in the number one great and then I'm going to type in the value Bob and I want a cat I guess I need to improve this just a little bit and do this you one a and there's the message and I might even just add an ampersand and then I'm going to put a period to make the end of the sentence like that okay I have a better idea let's fix this I don't like that that's a lot of concatenation there's an easier way to do this and I'll explain this little bit the syntax a little bit later but inside of that string what I'm going to do is add replacement syntax and there's some special features of replacement syntax that we're going to see in an upcoming lesson that will allow us to format what we put in here like if we have a date or a currency value we can do some really neat things but for right now I'll just use you won a curly brace zero curly brace double quote and then I'm going to use a comma after that and then put in the message like so okay now I need to explain these commas inside of the opening and closing parentheses you see that we have this if conditional method here and we use a bunch of commas what those are it allows us to separate the input parameters to each of those methods so sometimes a method only will accept a single input parameter like console dot right line now console dot right line can also accept two parameters or more in this case we're going to give it a string and then a value that could be used in replacement whenever it comes across a replacement code again we'll talk about replacement codes at length a little bit later but you can see here I'm passing in two parameters to the right line method by using a comma in between them here we're using three input parameters by using two commas here we do the evaluation is this going to be true or false if it is true then we give it the true part and then if it's false we give it the false part and whatever is returned back from this method whether it's car or cat it'll be assigned into our message variable which will then be added to our U1A and then we'll replace whatever that replacement code is whatever it's either car or cat exclamation mark at the end so now let's run the application again and here I'll type in the number 1 you want car see how that formatted it nicely and we'll run it again and this time we'll type in the number 4 you want a cat so we learned quite a bit in this lesson just tacking on some additional features of visual basic we looked at most importantly the if and else if and if statements in order to add some conditional logic to our applications so we made some decisions and based on values and evaluating the truthiness or falseness of a particular expression we're going to execute one of the code blocks inside of our if else if else and if code block alright we also looked at this magical if IIF method which allows us to again evaluate true or false and then return either a true or a false value that we can then like assign to a variable in this case then we also talked about how to add multiple items into input parameters using commas to separate each of the values in the input parameter and then finally we talked about this replacement syntax with curly braces and with the number zero inside of it and how we're able to replace a part of the string that we're giving to a right line by using the replacement code and then passing it the value we want to be stuck into that template okay for display alright so you're doing great we're learning a lot and let's continue on we're going to keep adding on the complexity and make our applications more and more interesting see in the next video hi I'm Bob Tabor with developer university for more of my training videos for beginners please visit me at devu.com in this lesson I want to spend a bit of time talking about some of the smaller syntax elements in visual basic that you'll need to master in order to understand how a properly formed line of code is constructed so in one of the first lessons I may have briefly referred to the visual basic syntax I'm driving nouns and verbs and punctuation and I want to elaborate on that just a little bit more and explain what I meant by that in this lesson so just like the English language has parts of speech and it has punctuation the same thing is true in software development and the visual basic programming language is no exception so we're going to talk about those building blocks to create those sentences those basic building blocks to create instructions in visual basic and so statements are like sentences statements are complete thoughts in visual basic they're like complete sentences and a statement is made up of one or more expressions and in turn an expression is made up of operators and operands so it goes statements statements are made up of expressions that consist of operators and operands so we've seen statements obviously just simply lines of code executable instructions that we've given the compiler whenever we type them into our module 1.vb expressions are some examples of expressions are things like a method call so console.write line passing in an empty string or hello world whatever the case might be whenever we use the if statement we evaluated an expression to see whether it evaluated a true or false so the expression portion of that was user value equals one so if user value equals one then execute this code block below it okay and then also there are expressions of assignment where we're assigning the value of a variable equal to some other value so each of those are examples of expressions and they have two things in common they are made up of operators and operands so an operand is similar to a noun in a sentence they're things that are that are that are nameable okay so variables that would be a good example of an operand but things like um literal strings that's an operand or a literal number like the number seven that would be an operand as well and so these are easy to remember because you're creating these yourself you're giving names to variables or or even classes or objects as we get further along um and you're giving value uh to uh literal numbers and literal strings right so operators are similar to verbs so you have operands are like nouns operators are like verbs and uh they will act on the nouns so they're things like for example the addition operator or the equality or Simon operator or the string concatenation operator uh typically you're going to use built-in operators whereas operands you name them yourselves typically operators are provided by the programming language now there's exceptions in both cases you could create your own operators or overload operators that's kind of an advanced topic so you know this is a little bit goofy I guess you could say and there's quite a few built-in operators and you're going to need to memorize many of them because it's how you're going to perform actions on your operands the things that you come up with the the intent of your code so fortunately as you're getting started uh you can use kind of a subset of all of the operators that are out there and then learn them commit them to memory over time and not have to refer to a cheat sheet whenever you need to to remember them so I'm going to help facilitate this what I did was create a project offline called operators expression statements and I merely created the code that you see here and you don't have to type this in yourself you can just open up this project if you want to follow along on your local computer uh because I don't know that there's any real value to typing this in this application doesn't really do anything it's just illustrating code ideas okay so if you run it it's not I don't even know it'll do anything honestly I don't think it has any yeah it has a console right line at the end but that's about it okay so uh just want to walk through quickly this is not an exhaustive list but this will give you a few to to chew on and to work with initially we've covered some of these already we'll we'll add on a few during this this lesson and you can expand your vocabulary of operators and keywords and so forth over time but in each of these cases uh an expression is made up of an operand like a literal string or a variable or an object um and an operator so an operator is something like the assignment operator so here we have an operand which is x and an operand which is the literal value of 3 and the operator is acting on the value of x so the way we would read this the value of 3 is being assigned to x all right so you see the associativity of the code and the direction it will go from right towards the left so anything on the right will be evaluated first and then it it gets assigned to the value that's on the left all right so that's the assignment operator we have the addition operator the subtraction operator the multiplication operator the division operator so these are things that you would probably come to expect uh then you can see uh we looked at the equality operator to see if two values are in fact equal or not true or false x equals y now there's some other variations on this we can check for example if x is greater than y now in numeric terms the greater than the less than operator the greater or equal to and the less than or equal to operators they're all pretty under easy to understand but you might be working with dates or strings in which case the greater than less than greater than or equal to less than or equal to might be a little harder to understand what is being compared um is it the length of the string is it the um the whether they're you know alphabetical order or not and so on all right then there are conditional operators the conditional or and the conditional and operator so that you can tie two expressions together and evaluate them so x is greater than y a is greater than b if either of these are true so if this is true or this is true then perform the code that you see in that code block the and operator is inclusive so both have to be true in order for this to happen so x must be greater than y and a must be greater than b in order for the code inside of the inside of the if statement to be to be uh to be executed all right we've also talked about the member access operator the period and how that allows us to uh to call a particular method of an object or a class in this case we've been calling the right line method of the console class by using the period in order to access it now when in this way the associativity goes from left to right so we start with the console object and then we call into its right line method and then we pass in a input parameter of a literal string and so in this case also I just want to point out that uh the double quotation marks that is the literal string operator and then there are other operators like for example the as operator you could say as is a keyword dim is a keyword that's all true sub is a keyword modules a keyword but if it acts on operands then it's also a operator in this case it acts on the operand to be assigning it a data type of integer alright so why am I telling you all of this well because the syntax rules of a programming language really do matter so for example um I can't just do that and expect anything to happen I mean visual basic compiler will look at that and say what are you trying to do you've only given me expression and an expression it it it's not a complete statement I need more than just an expression in order to do something ok so in this case we're only just doing x plus y but x plus y what alright what do you want me to do with this so in situations like these you can see visual studio will actually catch these syntactical errors uh as compilation errors we can't even run the application uh we can't even compile this code into a uh into an executable that will run inside of the dotnet framework clr the dotnet framework run time why not because the code cannot be compiled and um turned into a language that is uh acceptable by the dotnet framework run time so in that case you can see it the code editor gives us this red squiggly line letting us know that we have a problem in our code uh and so it anticipates the issues with the code by pre-compiling as we're typing alright if we were to hover our mouse cursor over we're going to get some very vague explanation as to the problem method arguments must be enclosed in parentheses so it thinks that what we're trying to do is um call um you know call some sort of method like this right and even so it's still going to have some issues alright so basically we don't even have enough code here for visual basic to give us a good error message unfortunately um and so essentially we just have to be aware of the fact that when we type in a line of code we have to kind of be purposeful and understand what it is we're trying to accomplish uh if we don't have the right set of expressions filled with operator and operands as we had here just a moment ago then we're not creating a properly form statement since we don't have a statement it can't really do anything with that code that we write so for beginners all you really need to understand is that there's a proper syntax in visual basic just like there are rules for the English language just like there is proper grammar in the English language so understanding that is a big step to solving your own problems whenever you're phrasing visual basic constructions that the visual basic compiler will accept and compile down into uh into a language that the .NET framework runtime can understand so I tell you what let's go ahead and stop right here let's recap the things that we talked about in this lesson first of all we said that statements are complete instructions in visual basic they consist of expressions and a statement is like a sentence in the English language and expressions are things that are that contain sounds and verbs the combination of the two so actual expressions are made up of operands and operators and an operand is a thing it's like a variable or a literal string something that we give value and importance to by naming it or giving it value and so for now you can think of for example the console class that's an operand and the variables that we've created those are operands whereas operators and we spent a lot of time looking at operators here and there are even more than that that we didn't talk about like I don't know if I said anything about the method invocation operators but this is definitely an operator that will kick off the execution of a method so there are lots of different types of operators and you'll need to learn the operators in order to perform actions on the operands that you create and that gives the instructions the proper instructions to that formulate your program now we've already been using these operators for all sorts of purposes until now even if we didn't identify them specifically as operators we're still using them and just understand that they are what actually do things in the application and just by using for example x or giving console you know by itself on its own line it's not going to accomplish anything we have to use operators and we have to use operands this is an operand in order to accomplish things in our applications and that's all I wanted to say hopefully that was helpful in diagnosing and understanding the code as you write it. Alright let's continue on the next lesson we're doing great. See there thanks. Hi I'm Bob Taber with Developer University for more of my training videos for beginners please visit me at devu.com in this lesson we're going to focus on iteration statements and a specific iteration statement the for next iteration statement. Sometimes you're just going to need to loop or iterate through a block of code to iterate through a sequence of items and maybe to perform a series of checks until you find a successful match maybe to execute the same code a number of times just because that's part of your business rules whatever the case might be actually you'll find yourself doing this more than you might anticipate and while it may not seem all that practically useful at first trust me you're going to need this in your toolbox as you start to write more interesting applications so let's create a new project and we're going to call this for next iterations and click OK and the syntax is really simple and I again I'm willing to bet that you're able to figure out what this will do without me telling you what it does so here we go there we go that's all we need so can you guess what you're going to see in the console window whenever we run the application let's see if you're right ok so if you guessed that you would see the numbers one through ten printed out into a console window you're right so basically all we're doing is executing the block of code defined by the four and the next statements in this case in lines five and seven anything between the four and the next will get executed a number of times until we've reached a certain condition in this case we're going to start off with the value one and assign one to index but once we get to assigning the number ten to index that'll be the last time we iterate through the code defined inside of the code block between the four and the next and then we break out and here we in line number nine we wait for the end user to move on that they have actually seen the content that we've printed to screen and that's pretty much all there is to it so we're instructing visual basic to execute a block of code a number of times and once we've completed that sequence of times as defined by this higher end boundary then we'll break out of the four next loop iteration statement and move on to the rest of our code alright so inside of here we can do some interesting things so like for example what if I were to go if index equals seven I could do something like then console dot right line you know found seven like so and we could run this and then once we get to the number seven we can print that out I have an idea why don't we shorten this just a little bit like before I don't think I showed you the then the then portion of the if else if else statement but you can use the then in order to combine everything on a single line like so alright so the then will allow you to combine a simple check with a result if index equals seven is true then go ahead and perform this line of code so we're able to condense three lines of code and do one line of code and now when we run it we get the exact same results okay I just wanted to show you that little use of the then keyword great and what if though let's comment that out and let's bust back over here to if index equals seven console dot right line found seven and now at this point we found what we were looking for if we wanted to break out of this loop we're no longer searching for the value we found what we were looking for we could do something like exit for and so now when we run the application the result looks a little bit different we get to seven we found seven and now we exit out of the four statement and we continue on executing our lines of code great this might be a good time to talk about one of the features of visual studio and again I'm trying to talk about visual studio but you still need some tools in your toolbox if we're going to build applications and one of those tools are the debugging tools of visual studio which is probably one of the best reasons to use visual studio you can actually pause and watch the execution of each line of code by simply setting a stop sign or break point in your code and then we execute the code and we get to that break point then we can continue to step through the code line by line or continue on and allow it to continue to execute the lines of code so to set a break point it's really easy in visual studio there's actually a number of different ways to do it but I find that the easiest way is to find this little gray column off to the left hand side underneath the tab heading and just click in that column for the line of code that you want to set a break point on so in this case I want to set a break point on line number six so I just click in the little gray area next to six and it creates this little stop sign over here on the left I guess it's a circle it looks more like an octagon to me and then it highlights the rest of that row in red and so now whenever we go to run the application and we're in debug time we're actually the execution of the application has stopped now unfortunately I got this little window that popped up let me get rid of that move it down but you can see that in this case the line of execution has stopped here on line number six and what we can do is hover our mouse cursor over the variables in this case there's only one variable but if I hovered over in this case the variable index we can see its current value and I can click what was formerly the start button it's now the continue button and when I run it I can and hover my mouse cursor over you can see that index has increased to two so when I clicked continue it executed the next several lines of code came back up to the top and we were able to break again on that same line of code since we're just iterating through the same block now I can use keyboard shortcuts or I can use these little items here in the toolbar while we're in debug mode to step through our code now I'm going to ignore the step into and the step out of they're kind of special cases and not really essential to us until we start building more complex applications but the step over is probably what we want to use I'm just going to hit the step over or F10 button on my keyboard and here I can just begin to step through each single line of code and I can continue to evaluate what the values are I can look at this autos window or the locals window or even the watch window and see the value of variables so in this case index is one of the local variables and I can see it here its name and its value and as it changes value notice that as we executed that that for loop in line number five the value turn from a black font to a red font indicating that the previous line of code changed the value of that variable so that's just a little visual cue to let us know that something just changed in our application let's see what else we can do here if I have a specific variable that I want to keep an eye on I can kind of highlight it and then drag and drop it into a watch window so that even if I am moved off to another part of the program I can always keep an idea keep an eye on the current value of the index in one of the watch windows so the other thing that you can do which is kind of neat is hover your mouse cursor over and see the current value of any given variable and I can even pin this down so notice that when I did that it pinned create this little pinned area and I can actually drag it and move it around so that as I start stepping through the code that little window pops up here and you might have seen it briefly change color to red whenever we hit the index six and continue moving on through our code here and at this point we'll see that index will in fact equal seven so we'll step into our if code block execute the console dot right line and then we'll see what happens when we hit the exit four it jumped from line number ten all the way to line number fourteen and if we hit continue now we'll just see this console window and we're back in runtime and hit the enter key and the keyboard to continue all right so those are just a really really quick overview of the features there is one cool feature that I want to show you that's applicable here since we're working with iteration statements and that is we can configure our breakpoint by clicking the little gear wheel that appears as we hover our mouse cursor over our breakpoint and I can say that I only want to break on this line under certain conditions and the condition that I want to that I want to break on is whenever index equals seven so whenever we hit that point I'm going to say let the breakpoint stop the execution of the code otherwise let's just go ahead and blow our way through one through six and so now I hit the continue button let's hover our mouse cursor over our index or I can just see it off here to the right hand side it is in fact seven I'm done with that now I could say I want to keep an eye on this and just keep that around or I can actually just get rid of the whole thing by just clicking the little X button there all right but you see how I was able to configure this breakpoint and make it conditional so that it only stops whenever the index value is equal to seven and there's some other options here that I could choose for example I could log a message when we hit a certain situation and then continue the execution we're not going to do any of that right now but notice this little tab breakpoint settings pops up in line very very neat and we can continue on the last thing that I want to show you and you can s