Sabtu, 17 Januari 2009

Microsoft Visual Basic

Visual Basic

What is Visual Basic?

Visual Basic is a "visual programming" environment for developing Windows (also Web now) applications. Visual Basic makes it possible to develop complicated applications very quickly. The programmer designs windows graphically, drags program elements from the Visual Basic Toolbox and writes basic code for each element. Visual Basic is "event-driven" which means that procedures are called automatically when the end user chooses menu items, clicks the mouse, moves objects on the screen, etc.

Why is Visual Basic popular?

Programmers have undergone a major change in many years of programming various machines. For example, what could take days to create an application in other programming languages like C, C++ could be done in hours with Visual Basic. Visual Basic provides many interesting sets of tools to aid us in building exciting applications. Visual Basic provides these tools to make our life far more easier because all the real hard code is already written for us.

Visual Basic is not only a programming language but also a true graphical development environment. This environment allows programmers with little programming experience to quickly develop powerful Windows applications. Visual Basic also has the ability to develop programs that can be used as a front-end application to a database system, serving as the user interface which collects user input and displays formatted output in a more appealing and useful form.

Visual Basic is very popular for the ease with which it allows the programmer to create nice looking graphical programs with less coding unlike many other languages that take thousands of lines of programmer keyed code. As the programmer works in the graphical environment much of the program code is automatically generated by the Visual Basic program.

Areas of Use

Using Visual Basic's tools we can quickly translate an abstract idea into a program design that we can actually see on the screen. VB encourages you to experiment, revise, correct, and network your design until the new project meets your requirements. However, most of all, it inspires your imagination and creativity. Visual Basic is ideal for developing applications that run on the Windows operating system. Developing applications with VB can be said to be a 3-step approach:

i) Design the appearance of application
ii) Assign property settings to the objects of the program
iii) Write the code to direct specific tasks at runtime

Visual Basic is used to develop applications in a number of different areas. Some of them are listed below:

* Accounting
* Business
* Commerce
* Consulting
* Education
* Law
* Marketing and Sales
* Medicine
* Research
* Science

Many of the things that we do with Visual Basic really aren’t very basic. The Visual Basic language is powerful, if you can imagine a programming task, it can be accomplished using Visual Basic.

History of Visual Basic

Microsoft first released Visual Basic in 1987. It was the first visual development tool from Microsoft, and it was to compete with C, C++, Pascal and other well-known programming languages. From the start, Visual Basic wasn't a hit. It wasn't until release 2.0 that people really discovered the potential of the language, and with release 3.0 it had become the fastest-growing programming language on the market.

Below is the order and the approximate year in which a new version of Visual Basic was released:

* 1991, VB1 Debuts
* 1992, VB2 Debuts
* 1993, VB3 Debut
* 1996, VB4 Debuts
* 1997, VB5 Debuts
* 1998, VB6 Debuts
* 2001, VB. NET Debuts



for syntax example:

Loops

For Loop

The For loop is the most popular loop. For loops enable us to execute a series of expressions multiple numbers of times. The For loop in VB .NET needs a loop index which counts the number of loop iterations as the loop executes. The syntax for the For loop looks like this:

For index=start to end[Step step]
[statements]
[Exit For]
[statements]
Next[index]

The index variable is set to start automatically when the loop starts. Each time in the loop, index is incremented by step and when index equals end, the loop ends.

Example on For loop

Module Module1

Sub Main()
Dim d As Integer
For d = 0 To 2
System.Console.WriteLine("In the For Loop")
Next d
End Sub

End Module







While loop

While loop keeps executing until the condition against which it tests remain true. The syntax of while loop looks like this:

While condition
[statements]
End While

Example on While loop

Module Module1

Sub Main()
Dim d, e As Integer
d = 0
e = 6
While e > 4
e -= 1
d += 1
End While
System.Console.WriteLine("The Loop ran " & e & "times")
End Sub

End Module

The image below displays output from above code.

Do Loop

The Do loop can be used to execute a fixed block of statements indefinite number of times. The Do loop keeps executing it's statements while or until the condition is true. Two keywords, while and until can be used with the do loop. The Do loop also supports an Exit Do statement which makes the loop to exit at any moment. The syntax of Do loop looks like this:

Do[{while | Until} condition]
[statements]
[Exit Do]
[statements]
Loop

Example on Do loop

Module Module1

Sub Main()
Dim str As String
Do Until str = "Cool"
System.Console.WriteLine("What to do?")
str = System.Console.ReadLine()
Loop
End Sub

End Module







Do Loop

The Do loop can be used to execute a fixed block of statements indefinite number of times. The Do loop keeps executing it's statements while or until the condition is true. Two keywords, while and until can be used with the do loop. The Do loop also supports an Exit Do statement which makes the loop to exit at any moment. The syntax of Do loop looks like this:

Do[{while | Until} condition]
[statements]
[Exit Do]
[statements]
Loop

Example on Do loop

Module Module1

Sub Main()
Dim str As String
Do Until str = "Cool"
System.Console.WriteLine("What to do?")
str = System.Console.ReadLine()
Loop
End Sub

1 komentar: