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.

No comments:

Post a Comment