Introduction To Programming Using Microsoft Visual Basic – Tutorial 01. - HOWTOTECH

Post Top Ad


Introduction To Programming Using Microsoft Visual Basic – Tutorial 01.

Share This

Introduction to Programming or Introduction to Visual Basic is a program run in IYA ABUBAKAR COMPUTER CENTER in AHMADU BELLO UNIVERSITY and I am giving to you now the very first tutorial on this subject but first I conclude that by now you should have been familiar with what Programming or Visual Basic Programming Software is but if you are not familiar with it I got you covered I explained every thing in details below. But first I will be starting with:


  • Know how to locate and open Microsoft Visual Studio IDE from within your computer
  • Familiarizing yourself with the Visual Studio IDE interface
  • Learn how to create and run simple console application in Visual Basic directly from Visual Studio IDE and Command line

How To Locate and Open/Run Microsoft Visual Studio IDE

Microsoft Visual Studio is an Integrated Development Environment (IDE) for creating, running and debugging programs (applications) written in a variety of supported programming languages (in this case, Visual Basic). An IDE is a way of bringing together a suite of tools that makes developing software a lot easier.
There are various ways to start Microsoft Visual Studio depending on your system configuration. Locate and fire up your Visual Studio IDE and see what you have got:
  1. From Start Menu: Select Start > All Programs > Microsoft Visual Studio 2010 >Microsoft Visual Studio 2010
Locate and Open/Run Microsoft Visual Studio
  1. From Desktop: If a shortcut labelled Microsoft Visual Studio 2010 exist on the desktop, double click on it to start the application.

Once the Visual Studio IDE begins execution, the Start Page displays. You’ll probably see a screen similar to the one below:

Locate and Open/Run Microsoft Visual Studio IDE 
The Start Page has a place for recent projects you’ve had open. From here, you could click on a recent project to open it or select a new project and start from scratch. The Start Page also has online help and some tutorials available just by clicking on the appropriate option. Feel free to look at them when you have time. By default the Start Page opens every time you start Visual Studio.

Menus and Toolbars Of Microsoft Visual Basic.

As explained earlier, an IDE (e.g. Visual Studio) is a collection of tools that makes programming easier. Developers (like you) make use of these tools during software development by executing some commands. These commands are grouped into menus. 
In Microsoft Visual Studio, menus are located in the menu bar. Each menu in the menu bar contains a collection of related commands. The Visual Studio menu bar is also dynamic, which means the set of menus displayed depends on what you are currently doing in the IDE.

Menus and Toolbars Of Microsoft Visual Basic.

Instead of navigating through series of menus to locate a command, Visual Studio provides quick access to frequently used commands via the toolbar which contains icons that represent commands. You may be familiar with some of these icons in other windows application like Microsoft Word. The toolbar is also dynamic in the sense that icons become active based on what you are currently doing. 

Creating Your First Console Application In Microsoft Visual Basic.

To finish your exploration of the Visual Studio IDE, you need to create an application so that the windows shown earlier have some interesting content for you to look at.

In Visual Basic, you create an application by developing a project. The project is stored in a folder and contains files and other folders. The finished executable program is stored in the bin folder which is located in the project folder and has an .exe extension.
  1. Select File > New Project… to display the New Project dialog. Alternatively you can click on the New Project icon on the toolbar or use the keyboard shortcut Ctrl+Shift+N

     Creating Your First Console Application In Microsoft Visual Basic. 
    How To Create Your First Console Application In Microsoft Visual Basic. 
  1. From the Installed Templates: section, select Windows if it is not selected.
  2. From the Templates: section, select Console Application if it is not selected.
  3. In the Name: field type “Welcome” as shown in the figure above.
  4. Click on the Ok button.
Having done with that, you get a window similar to this:

Creating Your First Console Application In Microsoft Visual Basic.

At this point, you can see that various windows in the IDE are beginning to show their purposes. An example is the Solution Explorer. The Solution Explorer displays the folder structure of your projects located within a Solution. A solution can have one or more projects and projects are made up of entities like Classes, Modules, Forms, images, etc.

By default, Visual Studio IDE creates a module called Module1 whenever you create a new project.

A module is just a logical collection of methods – methods perform a task and may return a value when the task is completed.

Every Visual basic code is stored in a file that ends with .vb extension. From Solution Explorer you can see that Module1 Module is stored in a file called Module1.vb. This name is not descriptive. So let’s rename the file to WelcomeModule.vb.
  1. On the Solution Explorer window, Click on Module1.vb.
Notice the changes in the Properties Window. The Properties window displays information about currently selected item in the Solution Explorer or Design Window.
  1. On the Properties Window Change the File Name property to WelcomeModule.vb.
  2. Press Enter key from your keyboard. Notice that the Module name in the code also changed to reflect the file name.

Few notes on Visual Basic syntax

keyword is a reserved word in the Visual Basic language. Keywords are used to perform a specific task in the computer program. E.g. Dim, Rem, If, Else, End, Sub

Comments are used by programmers to clarify the source code. All comments in Visual Basic follow either the ' character or the Rem keyword. Comments are ignored by the Visual Basic compiler.

White space in Visual Basic is used to separate tokens in the source file. It is used to improve readability of the source code. The amount of space put between tokens is irrelevant for the Visual Basic compiler. 
statement in Visual Basic is a complete instruction. A statement can be used for declaration or to initiate actions.

line continuation character ( _ ), is used if a statement spans more than one line otherwise compilation will fail.

Modifying WelcomeModule.vb code

  1. Click on WelcomeModule.vb tab to view the editor window
  2. In between Sub Main() and End Sub , type
Console.WriteLine(“Welcome to Visual Basic Programming!”)
console.write(“Welcome to Visual Basic Programming!”)

Saving your project
  1. Save your project by selecting File > Save All on the toolbar or by using the keyboard shortcutCtrl+Shift+S. For the first time, the Save Project Window appears.
Saving your project
  1. On the Location: field, type in the address. The format should be:
C:\VBPracticalProjects\<<your name>>
where <<your name>> will be replaced by your name. For example,
All subsequent practical exercises should be located in that folder.
  1. In the Solution Name, type in Tutorial01 since this is Tutorial01 of the tutorial practical. If you were on Tutorial02 the Solution Name will be Tutorial02 and so on.
  2. Make sure the Create directory for solution is checked.
  3. Click on Save button.
Running your first console application in Microsoft Visual Basic
You are now ready to compile and execute your application.
To compile the application:
  1. On the menu bar, select Build > Build Welcome. This creates a file called Welcome.exe inC:\VBPracticalProjects\Binoosmart\Part01\Welcome\bin\Release orC:\VBPracticalProjects\Binoosmart\Part01\Welcome\bin\Debug depending on your IDE configuration.
To execute the application:
  1. From the IDE select Debug > Start Without Debugging or use the keyboard shortcut Ctrl+F5.
  2. From windows command prompt, use cd command to navigate to the folder whereWelcome.exe file is located in your project.
  3. Type the name of the .exe file. In this case, Welcome.exe.
  4. Press Enter key from the keyboard.
Exercises For You, To Test What You Just Learn The Solution Is Below It.
  1. What is the difference between Console.WriteLine() and Console.Write()methods?
  2. Modify the Welcome project so that it displays the following text in one line.
Welcome to Visual Basic programming using Microsoft Visual Studio Integrated Development Environment!”

  1. Write an application (MyProfile) that displays your profile. An example output is displayed below. The output of the application should correspond to you.

Phone No.: +2348168374589

Name: Yakubu Binuyaminu

Sex: Male

Country: Nigeria

State: Kogi State

Religion: Islam

Save and run the Project as MyProfile under Tutorial01 Solution.
  1. Write an application that will output something similar to the output in the figure below:
Save the application as VShape under Tutorial01 Solution. (Hint: use spaces to separate the asterisks).

When you are done, Tutorial01 Solution should contain three projects namely:
  • Welcome,
  • MyProfile, and
  • Vshape

  1. The Basic difference between Console.WriteLine() and Console.Write() methods is that Console.WriteLine() will make each sentence or the item you want to display in be on a separate lines, each will have their lines. While the Console.Write() method is otherwise every statements been display by this method will bring out or display all output in one line. I think that English is Simple enough.
  2. Sub Main ()
      console.write(“Welcome to Visual Basic programming using Microsoft Visual Studio Integrated Development Environment!”)
      End Sub
      End Module
  3. Sub Main ()
      console.writeline(“Phone No.:    +2348168374589”)

      console.writeline(“Name:         Yakubu Binuyaminu”)

      console.writeline(“Sex:          Male”)

      console.writeline(“Country:      Nigeria”)

      console.writeline(“State:        Kogi State”)

      console.writeline(“Religion:     Islam”)
      End Sub
      End Module
  4. Sub Main ()
      console.writeline(“*              *”)
      console.writeline(“  *          *”)
      console.writeline(“    *      *”)
      console.writeline(“      *  *”)
      console.writeline(“        *”)
      End Sub
      End Module
    Watch out for the Tutorial 2 so that you wouldn't miss future tutorials like this one please subscribe with your Email. And keep coming back.

    Alright thanks for reading please if you like this tutorial share with your friends and don't hesitate to ask me any question in the comment section.

No comments:

Post a Comment

Please write your comments in accordance with the topic of this page post. Comments that contain links will not show up before they are approved

Post Bottom Ad