Thursday, January 24, 2013

Learning VB.NET


Setting up Visual Studio for your first application.

The first thing you will want to do if you haven't already is download Visual Studio. There are free versions called Visual Studio Express that contain the majority of what you will need for these tutorials. You will also want to download SQL Server if you do not already have it.
One important note is that I find Visual Basic the best language for learning, so all tutorials will be presented in VB. If you would like to learn C# you can use this tutorial, just know that you will spend a lot of time converting the code with an online and free conversion tool. I will make every effort to post all code at the end of each post so you can copy and convert it just once.

Links:
 choose the one you would like, I recommend Visual Studio Express 2012 For Windows Desktop
 I recommend ENU\x86\SQLEXPRWT_x86_ENU.exe
 This converts both ways, and it does a really good job of converting most code

Setup:
Create a new project, you should see Visual Basic under templates, select Windows, and then choose Windows Forms Application. Give your application a name, and click OK.




THE IDE (Integrated Development Environment)
Your next screen will look something like this. This is the IDE, it contains most of what you will use to design the layout of your application. I will break down the important areas below.



The Form
This is the actual form that will be displayed to the user, as you add new forms or code pages the tabs will be added above them (the blue tab below). Many years ago there were no GUIs (Graphical User Interface) everything happened at the command prompt, now we are used to Windows and iPads and the like which display files as icons rather than just text. Back then, and still some people/languages today, you have to program each piece of the GUI; if you want a button, you have to write the code for the button, set its location on the screen, its size, color, etc. The modern IDEs will for the most part let you do the design visually, rapidly speeding up the development process.



The Solution Explorer
Solution Explorer gives you a graphical view of your project, each connection, form, code page etc will be displayed here for visibility and ease of navigation. Though most objects can be created in many ways, this is the primary location for adding new forms, resources etc. The Solution Explorer may not appear on your screen in the same place I have mine, you can click and drag them anywhere you like, and even stack them inside each other (which is what I do).
Having tried many different layouts, I find the one shown here and in the IDE above to be the most convenient for me, primarily because I want the most used items showing at all times, while leaving plenty of room for form design.


The Toolbox
When designing your form, the Toolbox and Properties will be the menus you use the most, so it is good to have them easily available. The toolbox contains most of what you will need for quite a while, though other controls (including 3rd party controls and your own custom controls) can be easily added. You may not see the toolbox right away, it may be collapsed to the side of the IDE, or you may need to go make it visible from the menu (View->Toolbox). The toolbox can be moved and locked to any position as well.



 Properties
The properties tab shows you all of the properties associated with the control or object that is currently selected in the IDE to make it simple to change size, color, shape, font etc. The properties tab does not technically show all available properties, but it has all of the ones you can change without code. As you will learn in the future, you can create your own custom properties and have them appear in the properties box. If you don’t see this tab, you can add it from the menu with View->Properties Window.



Data Sources
The Data Sources window is where you manage the data sources used by your project, these can include various things but the most common are objects and databases. This can be added to the IDE if it is not already visible from the menu by clicking View->Other Windows->Data Sources




The Menu
Then menu works like most other menu’s, and yours may look different from the one below depending on your version. From the top row, the most commonly used are Project, and Build. The Project menu helps you with project specific settings including publishing your application and application wide settings, while the Build screen helps you build and rebuild your projects. More on these later when we will need them.
The second row contains the commands you will need to save and run your project which will be covered later. The bottom row is very helpful when designing the layout of your application, They can help with aligning the various controls so everything is aligned and tidy. This bar can be added by clicking View->Toolbars->Layout.








No comments: