Jump to content

Visual Basic

75% developed
From Wikibooks, open books for an open world

This book is written from a Visual Basic 6.0 perspective although much of what is said is also valid for Visual Basic 5.0 and Visual Basic 4.0. It does not cover VB.NET, a rather different language. It covers many different techniques and topics including object oriented programming, optimization of programs and coding guidelines.

Contents

[edit | edit source]
Introduction
This book's sole purpose is to help people better understand Visual Basic.
History
A timeline of Visual Basic's history.
Getting Started
VB6 IDE (Integrated Development Environment) is highly useful for developing GUI (Graphical User Interface) applications.
Simple Arithmetic
Introduction to calculating and operands with Visual Basic.
Branching
Branching occurs when the program makes a decision. The flow of execution follows a particular branch like a fork in the road.
Loops
Loops are control structures used to repeat a given section of code a certain number of times or until a particular condition is met.
Strings
Strings hold printable characters. They are very useful for communicating with human beings and for transferring data between programs and machines in text files and web pages.
Built In String Functions
Strings can be manipulated using simple string functions.
Regular Expressions
Complex string matching and manipulation can be achieved using a fairly sophisticated technique of regular expressions.
Arrays
Arrays are used to group data items of the same type together, to make it easier to search and sort through this data.
Collections
Array-like containers.
Dictionaries
Sets of key, value pairs.
Data Types
A datatype is a specification of the kind of information that a variable can hold, for example, a number or a piece of text.
Procedures and Functions
A function is a calling procedure or small part of a program that performs some specific task and returns a result; for example the cosine function.
Error Handling
Errors can be caught, handled and raised.
Files
While programming, you may want to at some point save data so they may be accessible for further use. This is where file I/O comes in. Visual Basic allows us to perform most operations available in Windows Explorer and DOS command line.
Date and Time
Dates and time need to be formatted, added, etc.
User Interfaces
Visual Basic supports creation of Graphical User Interfaces, which generally consists of one or more Forms that contain text boxes, labels, buttons, picture boxes, etc.
Simple Graphics
Visual Basic can easily be used to draw simple graphics such as line drawings and diagrams.
Windows Dialogs
Windows dialogs are useful when one requires standard interfaces, including opening files, saving files, choosing color and/or font, specifying printer settings.
Databases
Visual Basic can connect to databases in many different ways.
Windows API
APIs, short for "application programming interface", allows you to access a wide array of functions and methods exposed by the operating system or other applications (DLLs), performing operations not normally implemented by the standard virtual machine that Visual Basic provides.
Subclassing
Visual Basic hides the details of all the messages that Windows sends to an application but you can get at them if you really need to. Then you can do things that plain Visual Basic cannot.
External Processes
Sometimes you want to call another program from Visual Basic.
Object Oriented Programming
There is a lot of complicated talk about Object Oriented Programming but in essence it is quite simple.
Effective Programming
It isn't enough that the program work, you must be able to maintain it as well. Effective programmers can read their code as well as write it.
Idioms
An idiom is a sort of template or generic method of expressing an idea. In the same way that idioms in a human language make life easier for both the speaker and the listener, good idioms in computer programming make life easier for the programmer. Naturally what is idiomatic in one language might not be in another.
Optimizing Visual Basic
It is often desirable that your program not only does what you want it to do, but it also does it fast and with low memory footprint. Optimizing aims to improve the latter two requirements.
Examples
This section contains a number of ready made code examples for your use. They vary from short snippets to complete modules and short demo applications.
Case Studies
The Language
This section summarizes the syntax of Visual Basic and describes all the key concepts that of Visual Basic. It also notes some features that exist in other languages but do not exist in Visual basic.
Coding Standards
Consistent style in coding helps everyone to maintain a program whether the maintainer is the original author or not.
VB6 Command Reference
This section serves as guide to the commands that can be used in Visual Basic.
Glossary
Brief explanations of various important, difficult or otherwise interesting words and phrases with links to longer explanations in the body of the text.
Work in Progress
Various unfinished pages. Please look here for anything obscure or difficult.
Links
Contributors
[edit | edit source]
Data Structures
Programs operate on data so knowledge of effective data structures is very important.
Algorithms
Many algorithms were described long before computers were available and many have both naive inefficient forms and sophisticated efficient forms. In many cases this is independent of the implementation language.
Object Oriented Programming