Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
20 views

Computer Programing 2

CompProg1

Uploaded by

Avc Ccss
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Computer Programing 2

CompProg1

Uploaded by

Avc Ccss
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Computer Programing 2

Computer programming concept


Designing a set of instructions to instruct a computer to carry out certain jobs that are very much faster than human
beings can do is called programming. A machine language is the earliest programming language which uses the
binary code to communicate with the computer.
However, this language is difficult to learn. The high- level programming languages such as Java, C, C++, c# and Visual
Basic are much easier to master.

The Visual Basic


Visual Basic is a third- generation event- driven programming language first released by Microsoft in 1991. It evolved
from the earlier DOS version called Basic. Basic means Beginners’ All- Purpose Symbolic Introduction Code. Since
then Microsoft has released many versions of Visual Basic, from VB1.0 to the final version VB6.0. Visual Basic is a
user-friendly programming language designed for beginners, and in enables anyone to develop GUI window
applications easily.

Visual Basic.Net (VBNET) replaces VB6 in 2002 but Microsoft still provides some support for VB6.VB.NET is a fully
object- oriented programming language implemented in the .NET Framework. It was created to cater for the
development of the web as well as mobile applications. However, many developers still favor Visual Basic 6.0 over its
successor Visual Basic.NET.

Programming with Visual Basic


In VB6, you can create any programs depending on your objective. You can create mathematical programs such as
Geometric Progression, Quadratic Equation Solver, Simultaneous Solver, Prime Number Tester, Factors Finder, and
Quadratic Function Graph Plotter and so on. If you are in business, you can also create business applications such as
inventory management system, calculator, point-of-sale system, payroll system, accounting programs and more to
help manage your business and increase productivity. If you are interested with games, you can create a programs
such as slot machine, tic tac toe and more.

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
VB.Net has strong programming features that make it endearing to multitude of programmers worldwide. Some
features are:
 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

We have already mentioned that VB.Net is part of .Net Framework and use for writing .Net applications. Therefore,
before discussing the available tools for running a VB.Net program let us understand how VB.Net relates to the .Net
Framework.

The .Net Framework


The .Net Framework is a revolutionary platform that helps you to write the following types of applications – windows
applications, web applications and 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: C#, C++,
Jscript, and COBOL, etc. These languages can access the framework as well as communicate with each other.

*Search on the Components of the .Net Framework and its job. (Provide a list on your paper and attach it on the last
page.)

*Advance Learning – Create a “What is your name” application


Let’s create an app that prompts for your name and displays it along with the date and time, but first download a
Visual Studio 2019 and .Net on https://visualstudio.microsoft.com/vs/
https://visualstudio.microsoft.com/vs/features/net-development/
*Try it yourself. (Activity 1 – Print a screenshot of your activity and attach.)

Create a project
First, we’ll create a Visual application project. The project type comes with all the template files you’ll need, before
you’ve even added anything.
1. Open Visual Studio 2019.
2. On the start window, choose Create a new project.
3. On the Create a new project window, enter or type console in the search box. Next, choose Visual
Basic from the Language list, and then choose Windows from the Platform list. After you apply the language
and platform filters, choose the Console App (.NET Core) template, and then choose Next.
4. In the Configure your new project window, type or enter WhatIsYourName in the Project name box. Then,
choose Create.

To create a “What’s your Name” application, follow the steps below.


1. In the WhatIsYourName project, enter the following Visual Basic code immediately after the opening bracket
that follows the Sub Main(args As String()) line and before the End Sub line:

2. Use the green Start button, or press F5 to build and run your first app.
3. When the console window opens, enter your name. Your console window should look similar to the
following screenshot:

4. Press any key to close the


console window.
Integrated Development Environment (IDE) For VB.Net
Microsoft provides the following development tools for VB.Net programming −
 Visual Studio 2010 (VS)
 Visual Basic 2010 Express (VBE)
 Visual Web Developer
The last two are free. Using these tools, you can write all kinds of VB.Net programs from simple command-line
applications to more complex applications. Visual Basic Express and Visual Web Developer Express edition are
trimmed down versions of Visual Studio and has the same look and feel. They retain most features of Visual Studio.
In this tutorial, we have used Visual Basic 2010 Express and Visual Web Developer.

Writing VB.Net Programs on Linux or Mac OS

Although the.NET Framework runs on the Windows operating system, there are some alternative versions that
work on other operating systems. Mono is an open-source version of the .NET Framework which includes a Visual
Basic compiler and runs on several operating systems, including various flavors of Linux and Mac OS. The most
recent version is VB 2012.
The stated purpose of Mono is not only to be able to run Microsoft .NET applications cross-platform, but also to
bring better development tools to Linux developers. Mono can be run on many operating systems including
Android, BSD, iOS, Linux, OS X, Windows, Solaris and UNIX.
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

 Imports System
 Module Module1
 'This program will display Hello World
 Sub Main()
 Console.WriteLine("Hello World")
 Console.ReadKey()
 End Sub
 End Module
 When the above code is compiled and executed, it produces the following result − Hello, World!

Look at the various part of the 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 −
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. The Main
procedure states what the module or class will do when executed.
 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.

Compile & Execute VB.Net Program


If you are using Visual Studio.Net IDE, take the following steps −
 Start Visual Studio.
 On the menu bar, choose File → New → Project.
 Choose Visual Basic from templates
 Choose Console Application.
 Specify a name and location for your project using the Browse button, and then choose the OK button.
 The new project appears in Solution Explorer.
 Write code in the Code Editor.
 Click the Run button or the F5 key to run the project. A Command Prompt window appears that contains the
line Hello World.

You can compile a VB.Net program by using the command line instead of the Visual Studio IDE −
 Open a text editor and add the above mentioned code.
 Save the file as helloworld.vb
 Open the command prompt tool and go to the directory where you saved the file.
 Type vbc helloworld.vb and press enter to compile your code.
 If there are no errors in your code the command prompt will take you to the next line and would
generate helloworld.exe executable file.
 Next, type helloworld to execute your program.
 You will be able to see "Hello World" printed on the screen.

*Let’s Review. (Answer the following questions. Provide your answer in the blank.)

1. What language is the earliest programming language which uses the binary code to communicate with the
computer? _______________
2. It is a revolutionary platform that helps you to write the following types of applications – windows
applications, web applications and web services. ____________
3. It is used to include the System namespace in the program. ____________
4. It is a method of the Console class defined in the System namespace. ____________
5. To run the program you must ______________________________.

NEXT LESSON: CLASS, OBJECT, METHODS, INSTANCE VARIABLES

You might also like