Friday, June 28, 2013

Getting Started in VB.Net

We can create VB.Net Programs through Microsoft Visual Studio for Windows and Mono for other operating systems. We can actually compile VB.Net programs online. You can try it here. We have 4 versions of Visual Studio Software. Visual Studio 2008, 2010, 2012 and 2013.

Visual Studio 2008 - Not recommended for Download
Download Visual Studio 2010 here.
Download Visual Studio 2012 here.
Download Visual Studio 2013 here.

You need to sign up first to download the application.

After installing the Microsoft Visual Studio. I can now show you how to create a VB.Net project.
  1. Open MS Visual Studio (I'm using Visual Studio 2010)
  2. Click New Project or key in Ctrl+Shift+N on your keyboard
  3. Find Visual Basic on Intalled Templates tab on the left-side of the pop-up window.
  4. Click Windows Forms Application
  5. Rename the default filename to My First Program in VB.Net (A new folder will be created on the File directory with the same name as your filename. This will hold all the files that is associated with your project. 
  6. Keep the location same as default.
  7. Click OK.
  8. Now a form be seen on the screen. The default name is Form1. You can see its properties by Right-Click on the mouse and click Properties.
  9. You can rename the form. Find the Name Property and rename it to MyForm1. Find Text Property and enter My First Form. 
  10. Try running this program by pressing F5 or click debug on the menu bar. 
  11. You can see that there are 2 different views. The design environment and debug environment.
  12. Design environment is where we add controls (label, textbox, button, etc. ) to the form and code of course. Debug is where we test our program.
  13. To add controls (label, textbox, button etc.) press Ctrl+Alt+X or click View on the menu bar and click ToolBox. 
  14. Under ToolBox, we'll see set of controls. We're going to create a simple form with a label, textbox and button.
  15. Double click label on the ToolBox. Place it on the left side of the form and Right-click and click Properties and locate Name Property and rename it to lblName, set Text Property to Name:
  16. Add textbox to your form. Double click or single click and click on the form and click and drag the textbox next to label. Change its Name property to txtboxName.
  17. Last Add Button to your form. Change the Name property to btnOk. Change Text Property to OK. 

  18. Double Click on the Button. Write the following code where the cursor goes when you click on the button control.
        Dim name As String
        name = txtboxName.Text
        MsgBox("Hello " & name)




PRESS F5 and you should see this. Enter your name to the textbox.


That's it! You've just created your First VB.Net Form

Please email me @ lizducos17@gmail.com or leave a comment below.

Wednesday, June 26, 2013

Introduction to VB.Net


Visual Basic.Net


VB.Net is a simple, modern, object-oriented computer programming language developed by Microsoft to combine the power of the .NET Framework and the common language runtime with the productivity benefits that are the hallmark of Visual Basic.

Visual Basic .NET is one of the two flagship languages (with C#) for the .NET framework from Microsoft. Despite being called Visual Basic, it is actually not backwards-compatible with VB6, and any code written in the old version will not compile under VB.NET.

As a language, Visual Basic.NET has the following traits:

Object-Oriented


As with all .NET languages, VB.NET includes full-blown support for object-oriented concepts, including simple inheritance. Everything in VB.NET is an object, including all of the primitives (Short, Integer, Long, String, Boolean, etc.) as well as types, events, and even assemblies. Everything inherits from the Object base class.

Event-Driven


All previous versions of Visual Basic were event-driven, but this feature is heavily enhanced under the .NET framework. Events are no longer recognized because they use a certain naming convention (ObjectName_EventName), but now are declared with a Handles ObjectName.EventName clause. Event handlers can also be declared at runtime using the AddHandler command.

.NET Framework


As the name implies, VB.NET runs on top of Microsoft's .NET framework, meaning the language has full access to all of the supporting classes in the framework. It's also possible to run VB.NET programs on top of Mono, the open-source alternative to .NET, not only under Windows, but even Linux or Mac OSX.

HISTORY


Visual Basic was initially introduced in 1991 as the first programming language that directly supported programmable graphical user interfaces using language-supplied objects. From that time until 2002, there were five other versions released, each version having features that increased the power of the language. In 2001, Microsoft released the .NET (pronounced “dot net”) platform. Visual Basic .NET, or VB.NET, is an upgrade to the last version of VB (version 6.0) that conforms to the .NET platform. As you will see in subsequent chapters, the changes in VB.NET allow programmers to write Web or desktop applications within the same language. In addition, VB.NET is fully object-oriented as opposed to prior versions that had many, but not all, of the elements of an object-oriented language. This book is based on VB.NET. In the balance of the book we will sometimes refer to Visual Basic as VB, omitting .NET.

 

The following reasons make VB.Net a widely used professional language:

·         Modern, general purpose.
·         Object oriented.
·         Component oriented.
·         Easy to learn.
·         Structured language.
·         It produces efficient programs.
·         It can be compiled on a variety of computer platforms.
·         Part of .Net Framework.

Strong Programming Features VB.Net


VB.Net has numerous strong programming features that make it endearing to multitude of programmers worldwide. Let us mention some of these features:

·         Boolean Conditions
·         Automatic Garbage Collection
·         Standard Library
·         Assembly Versioning
·         Properties and Events
·         Delegates and Events Management
·         Easy to use Generics
·         Indexers
·         Conditional Compilation
·         Simple Multithreading