VISUAL PROGRAMMING
VISUAL BASIC(VB.Net)
BSCS-6th SEMESTER
Course Instructor: Mr.Malak Roman
Lecturer CS/IT
CS Department
University of Chitral
INTRODUCTION TO VISUAL BASIC
Microsoft Visual Basic, the latest and greatest incarnation of the
old BASIC language, gives you a complete Windows application
development system in one package.
Visual Basic (or VB, as we often call it) lets you write, edit, and
test Windows applications.
In addition, VB includes tools you can use to write and compile
help files, ActiveX controls, and even Internet applications.
Controls are tools on the Toolbox window that you place on a
form to interact with the user and control the program flow.
Programming
A program is a set of instructions that make the computer do
something such as perform accounting.
(The term program is often used synonymously with
application.)
Visual Basic is itself a Windows application.
You load and execute the VB system just as you do other
Windows programs.
You will use this running VB program to create other programs.
VB is just a tool, although an extremely powerful tool, that
programmers (people who write programs) use to write, test,
and run Windows applications.
Project
A project is a collection of files you create that comprises your
Windows application.
Although programmers often use the terms program and
application interchangeably the term application seems to fit
the best when you’re describing a Windows program because a
Windows program typically consists of several files.
These files work together in the form of a project.
The project generates the final program that the user loads and
runs from Windows by double-clicking an icon or by starting
the application with the Windows Start menu.
Visual Programming
An application is a collection of one or more files that compile
into an executable program.
A programming language today, such as Visual Basic, differs
greatly from programming languages of just a few years ago.
Before windowed environments, a programming language was a
simple text-based tool with which you wrote programs.
Graphical development tool that can work inside the Windows
system and create applications that take advantage of all the
graphical, multimedia, online, and multiprocessed activities
that Windows offers.
Visual Basic is such a tool.
Visual Basics (VB.Net)
VB.Net is a simple, modern, object-oriented computer
programming language developed by Microsoft to combine the
power of .NET Framework and the common language runtime
with the productivity benefits that are the hallmark of Visual
Basic
VB.NET is implemented by Microsoft's .NET framework.
Therefore, it has full access to all the libraries in the .Net
Framework.
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
The .Net Framework
The .Net framework is a revolutionary platform that helps you to
write the following types of applications −
1. Windows applications
2. Web applications
3. Web services
The .Net framework applications are multi-platform applications.
The framework has been designed in such a way that it can be used
from any of the following languages:
Visual Basic, C#, C++, Jscript, and COBOL, etc.
All these languages can access the framework as well as
communicate with each other.
The .Net framework consists of an enormous library of codes used
by the client languages like VB.Net.
These languages use object-oriented methodology.
Following are some of the components of the .Net framework
Common Language Runtime (CLR)
The .Net Framework Class Library
Common Language Specification
Common Type System
Metadata and Assemblies
Windows Forms
ASP.Net and ASP.Net AJAX
ADO.Net
Windows Workflow Foundation (WF)
Windows Presentation Foundation
Windows Communication Foundation (WCF)
VB.Net - Program Structure
A VB.Net program basically consists of the following parts −
Namespace declaration
A class or module
One or more procedures
Variables
The Main procedure
Statements & Expressions
Comments
VB.Net - Program Structure...
Let us look at a simple code that would print the words "Hello
World"
When the above code is compiled and executed, it produces the
following result Hello World
VB.Net - Program Structure...
Look various parts of the above program
The first line of the program Imports System is used to include
the System namespace in the program.
The next line has a Module declaration, the module Module1.
VB.Net is completely object oriented, so every program must
contain a module of a class that contains the data and
procedures that your program uses.
Classes or Modules generally would contain more than one
procedure.
Procedures contain the executable code, or in other words, they
define the behavior of the class.
A procedure could be any of the following
VB.Net - Program Structure...
A procedure could be any of the following −
Function
Sub
Operator
Get
Set
AddHandler
RemoveHandler
RaiseEvent
The next line( 'This program) will be ignored by the compiler
and it has been put to add additional comments in the program.
The next line defines the Main procedure, which is the entry
point for all VB.Net programs.
VB.Net - Program Structure...
The Main procedure specifies its behavior with the statement
Console.WriteLine("Hello World") WriteLine is a method of
the Console class defined in the System namespace. This
statement causes the message "Hello, World!" to be displayed
on the screen.
The last line Console.ReadKey() is for the VS.NET Users. This
will prevent the screen from running and closing quickly when
the program is launched from Visual Studio .NET.
C-Sharp (C#)
C# is a modern, general-purpose, object-oriented programming
language developed by Microsoft and approved by European
Computer Manufacturers Association (ECMA) and
International Standards Organization (ISO).
C# was developed by Anders Hejlsberg and his team during the
development of .Net Framework.
C# is designed for Common Language Infrastructure (CLI),
which consists of the executable code and runtime environment
that allows use of various high-level languages on different
computer platforms and architectures.
C-Sharp (C#)
The following reasons make C# a widely used professional
language
It is a modern, general-purpose programming language
It is object oriented.
It is component oriented.
It is easy to learn.
It is a structured language.
It produces efficient programs.
It can be compiled on a variety of computer platforms.
It is a part of .Net Framework.
C-Sharp (C#)
The following reasons make C# a widely used professional
language
It is a modern, general-purpose programming language
It is object oriented.
It is component oriented.
It is easy to learn.
It is a structured language.
It produces efficient programs.
It can be compiled on a variety of computer platforms.
It is a part of .Net Framework.
C# - Type Conversion
Type conversion is converting one type of data to another type.
It is also known as Type Casting.
In C#, type casting has two forms
Implicit type conversion − These conversions are performed
by C# in a type-safe manner. For example, are conversions from
smaller to larger integral types and conversions from derived
classes to base classes.
Explicit type conversion − These conversions are done
explicitly by users using the pre-defined functions. Explicit
conversions require a cast operator.
C# - Type Conversion
C# Type Conversion Methods
C# provides the following built-in type conversion methods
ToBoolean
Converts a type to a Boolean value, where possible.
ToByte
Converts a type to a byte.
ToChar
Converts a type to a single Unicode character, where possible.
ToDateTime
Converts a type (integer or string type) to date-time structures.
ToDecimal
Converts a floating point or integer type to a decimal type.
ToDouble
Converts a type to a double type.
ToInt16
Converts a type to a 16-bit integer.
ToInt32
Converts a type to a 32-bit integer.
C# - Type Conversion
ToInt64
Converts a type to a 64-bit integer.
ToSbyte
Converts a type to a signed byte type.
ToSingle
Converts a type to a small floating point number.
ToString
Converts a type to a string.
ToType
Converts a type to a specified type.
ToUInt16
Converts a type to an unsigned int type.
ToUInt32
Converts a type to an unsigned long type.
ToUInt64
Converts a type to an unsigned big integer.
?