Basic Programming Language In Visual Studio IDE : Part 1
By: Luis A. Sierra
• Most of the projects we will do to explain the use of the language will be in the Windows Console (command-line) interface. In this way, the use of the basic language can be understood natively so that the reader can clearly understand the instructions of the language.
• Once the language has been mastered, the use of visual controls and their characteristics in a Visual Studio IDE will be explained.
• At the end of use this tutorial the reader will can create and design an application they want with the basic language in Visual Studio.
History
In 1991, Microsoft introduced Visual Basic, an evolutionary development of QuickBASIC. It included constructs from that language such as block-structured control statements, parameterized subroutines and optional static typing as well as object-oriented constructs from other languages such as "With" and "For Each".
The language retained some compatibility with its predecessors, such as the Dim keyword for declarations, "Go Sub" Return statements and optional line numbers which could be used to locate errors. An important driver for the development of Visual Basic was as the new macro language for Microsoft Excel, a spreadsheet program.
To the surprise of many at Microsoft who still initially marketed it as a language for hobbyists, the language came into widespread use for small custom business applications shortly after the release of VB version 3.0, which is widely considered the first relatively stable version. Microsoft also spun it off as Visual Basic for Applications and Embedded Visual Basic.
While many advanced programmers still scoffed at its use, VB met the needs of small businesses efficiently as by that time, computers running Windows 3.1 had become fast enough that many business-related processes could be completed "in the blink of an eye" even using a "slow" language, as long as large amounts of data were not involved.
Many small business owners found they could create their own small, yet useful applications in a few evenings to meet their own specialized needs. Eventually, during the lengthy lifetime of VB3, knowledge of Visual Basic had become a marketable job skill. Microsoft also produced VBScript in 1996 and Visual Basic .NET in 2001.
The latter has essentially the same power as C# and Java but with syntax that reflects the original Basic language, and also features some cross-platform capability through implementations such as Mono-Basic. The IDE, with its event-driven GUI builder, was also influential on other tools, most notably Borland Software's Delphi for Object Pascal and its own descendants such as Lazarus.
Mainstream support for the final version 6.0 of the original Visual Basic ended on March 31, 2005, followed by extended support in March 2008. Owing to its persistent remaining popularity, third-party attempts to further support it, such as Rubberduck and ModernVB, exist.
On February 2, 2017 Microsoft announced that development on VB.NET would no longer be in parallel with that of C#, and on March 11, 2020 it was announced that evolution of the VB.NET language had also concluded. Even so, the language was still supported and the third-party Mercury extension has since been produced.
Meanwhile, competitors exist such as B4X, RAD Basic, twinBASIC, VisualFBEditor (FreeBasic), Xojo, and Gambas.
IDEs
Visual Basic is an easy language to learn but with many flaws. Much of these deficiencies is the result of its eager objective to be simple for the novice programmer. It is a light object-oriented language. It has some of the most popular OOP features implemented, but many of them (the
that we really miss in complex projects) remain absent, like the inheritance, virtual methods, operator overloading, etc.
Of course, VB also has many virtues. Make a Windows application has never been easier, and if certain tasks are out of reach of the language, it is possible to make a component in, for example, C++ and use it from VB without problems..
You can download and install a Visual Studio Community version from visualstudio.com.
Now we will see how to create a console application using visual studio in a visual basic programming language.
Console Applications
A Console Application project is easy to set up; the steps to do this will be explored below. Console applications use the .NET Console class. The "Try It" sample programs will use of the Read or ReadLine methods for input and the Write or WriteLine methods for output.
These methods are described briefly in the table below:
![]() |
Create a Project in Visual Studio
Create a new console application using a visual basic programming language; for that, Go to File => New and select a Project like as shown below.
Once you click on Project, a new popup will open in that select Visual Basic from the left pane and choose Console App. In the Name section, give any name for your project and select an appropriate Location path to save your project files, and click OK like as shown below.
Once we click on the OK button, a new console application will be created.
Add the code below and Start
Module Module1
Sub Main()
Console.WriteLine("Hello World")
Console.ReadLine()
End Sub
End Module
This is how we can create a console application in a visual basic programming language using a visual studio.
Variables
Variables are the "place" where we can store the data that the program needs.
The variables have four characteristics:
- A name
- A type of data
- Access Modifiers
- A lifetime
All variables have a name, this name is what we are going to call it by so that it returns its value. Also when declaring it we must assign a data type, for example:
If I were programming and it were an integer variable, for example, it would be:
Note: "Dim" is a Private by default
In visual basic, Access Modifiers are the keywords and those are useful to define an accessibility level for all the types and type members.
By specifying the access level for all the types and type members, we can control whether they can be accessed in other classes or in current assembly or in other assemblies based on our requirements.
The following are the different types of access modifiers available in a visual basic programming language.
- Public
- Private
- Protected
- Friend
By using these four access modifiers, we can specify a following six levels of accessibility for all types and type members based on our requirements.
Constants
Constants are fixed values that are not changed during the execution of the program. These fixed values are also referred to as literals.
Constants can be of any basic data kinds, such as integers, characters, floating points, or string literals. Enumeration constants are also available.
Constants are processed similarly to regular variables, except that their values cannot be changed after they are defined.
Line Termination
A line terminator divides the characters of a Visual Basic source file into lines.
Example:
Case Sensitivity
Case sensitivity defines whether uppercase and lowercase letters are treated as distinct or equivalent.
"VB.NET is not case sensitive"
Initialization is the process of assigning a value to the Variable.
"VB.NET: Automatically initialize variables to ZERO or Nothing"
Type Conversions
Is the process of converting one data type to another. The type conversion is only performed to those data types where conversion is possible.
The following table shows the available conversion keywords.
The CType Function operates on two arguments. The first is the expression to be converted, and the second is the destination data type or object class. Note that the first argument must be an expression, not a type.
Example: How to convert an Integer to String using a CType Funtion.
An array is a data structure consisting of a collection of elements, of same memory size, each identified by at least one array index or key. An array is stored such that the position of each element can be computed from its index.
Example: How to use a Visual Basic Arrays
- Arithmetic Operators
- Assignment Operators
- Logical/Bitwise Operators
- Comparison Operators
- Concatenation Operators
The following table lists the different arithmetic operators available in Visual Basic.
The following table lists the different types of logical/bitwise operators available in Visual Basic.
The following table lists the different comparison operators available in Visual Basic.
if/else Statement
The if-else statement is used to execute both the true part and the false part of a given condition. If the condition is true, the if block code is executed and if the condition is false, the else block code is executed.
Example 1:
Example 2:
CASE Statement
The CASE expression goes through conditions and returns a value when the first condition is met (like an if-then-else statement)
Example:
For Statement
The for statement, also called the for loop, lets you repeat a statement or compound statement a specified number of times.
Example 1 - Up:
Example 2 - Step:
Example 3 - Down:
For/Each Statement
The for/each statements allow you to loop through an array of data and render the results in a message.
Example:
While Statement
A while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition.
Example:
Method
A method in object-oriented programming (OOP) is a procedure associated with an object, and generally also a message. An object consists of state data and behavior; these compose an interface, which specifies how the object may be used. A method is a behavior of an object parametrized by a user.
Note: Methods do not return value.
Example:
Function
Note: functions return a value.
Exmaple:
A class is an extensible program-code-template for creating objects, providing initial values for state (member variables) and implementations of behavior (member functions or methods).
Example:
1 - Create a new console application using a visual basic (You Know Now How to do it)
2 - Go to Solutions Explorer and add a Class file like i show you below:
3 - Now add some functions to the Class file like i show you below:
4 - Now call the Class functions from the Main Method like i show you below:
Properties
Example:
1 - Create a new console application using a visual basic (You Know Now How to do it)
2 - Go to Solutions Explorer and add a Class file (You Know Now How to do it)
3 - Create the example Property code to a class like i show below:
4 - Now call the Class Property from the Main Method and Set a Value for get later as i show you below:
Inheritance
Inheritance is one of the core features of object-oriented programming. It's a programming procedure that allows you to reuse code by referencing the behaviors and data of an object. In other words, a class that inherits from another class shares all the attributes and methods of the referenced class.
Note: In .NET Only simple inheritance is allowed
Example:
1 - Create a new console application using a visual basic (You Know Now How to do it)
2 - Go to Solutions Explorer and add a Class1 file (You Know Now How to do it)
3 - Go to Solutions Explorer and add a Class2 file (You Know Now How to do it)
4 - Go to Class1 and add the code below:

5 - Go to Class2 and add the code below:

6 - Now call the Class2 from the Main Method like i show you below:
Note: In .NET Only simple inheritance is allowed
Example:
1 - Create a new console application using a visual basic (You Know Now How to do it)
2 - Go to Solutions Explorer and add a Class1 file (You Know Now How to do it)
3 - Go to Solutions Explorer and add a Class2 file (You Know Now How to do it)
4 - Go to Class1 and add the code below:
5 - Go to Class2 and add the code below:
6 - Now call the Class2 from the Main Method like i show you below:
Exception handling
Exception is typically used to denote a data structure storing information about an exceptional condition. One mechanism to transfer control, or raise an exception, is known as a throw; the exception is said to be thrown. Execution is transferred to a catch.
Example:





Post a Comment