WEBINAR: On-demand webcast
How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >
Introduction to Microsoft Visual Studio 2010
In the last installment of Visual Basic .NET Development 101 we looked at a few basic steps to start programming with Visual Basic 2010 Express Edition. The last thing we mentioned was the Properties window and Solution Explorer window. By default, you'll only see the design surface on a tab named
Form1.vb [Design] (see Figure 1). If you double-click on the button, you'll open a new tab showing the source code for Button1's event handler. For now, let's just type in one line of code to open up a message box when you click the button.
MsgBoxhighlighted in the popup window. Microsoft Visual Studio will enter MsgBox for you if you hit the space bar or tab key. If you enter a left-parenthesis "(" you'll get the full MsgBox plus the parenthesis and be ready to type in the arguments. Figure 2 shows what you should see at this point.
Now we're ready to finish our first little program. Here's what you need to enter:
Msgbox("Hello from Visual Basic 2010 Express")
At this point you have a fully functional Windows Forms application. All you have to do to run it is either click on the run icon (looks like a green play button) in the toolbar or press the F5 function key. The initial screen with our Click Me button will appear. If you click it, another smaller message box dialog will appear with our Hello message and an OK button (see Figure 3). To close the application you can either click on the red X in the top right-hand corner of the form or click on the Stop button (small blue square next to the run button) in the toolbar.
A few more things need to be pointed out here before we move on. When the
From1.vb tab is active, or has focus, you won't see anything in the designer toolbox as they don't apply to the current window. When you click on the design tab, the toolbox will repopulate. If you happen to close either of the windows, you can quickly reopen them from the Solution Explorer. The quickest way is to right-click on the
Form1.vb item and choose either View Code or View Designer (see Figure 4). You could also use the F7 or Shift-F7 function keys as well.
Visual Basic 2010 Express will automatically save your project for you each time you run it. Every application has a number of default settings defined for you when you create a new project. You can change those by right-clicking on the
WindowsApplication1 project name in the Solution Explorer and choosing Properties. It's also available from the Project menu under
WindowsApplication1 Properties. The title will change with the name of your application.
Microsoft Visual Studio 2010 has a world of other options and features, but we'll address them as they come up along the way. For now, you have enough information to create a few simple applications on your own so go ahead and get started!