Category Archive for: Visual Basic: The Language

Nested Control Structures

You can place, or nest, control structures inside other control structures (such as an If… Then block within a For … Next loop). Control structures in Visual Basic can be nested in as many levels as you want. It’s common practice to indent the bodies of nested decision and loop structures to make the program easier to read. Here…

Read More →

Loop Statements

Loop statements allow you to execute one or more lines of code repetitively. Many tasks consist of trivial operations that must be repeated over and over again, and looping structures are an important part of any programming language. Visual Basic supports the following loop statements: Do Loop For Next While … Wend Do… Loop The Do … Loop…

Read More →

Control Flow Statements

What makes programming languages flexible and capable of handling every situation and programming challenge with a relatively small set of commands is the capability to examine external conditions and act accordingly. Programs aren’t monolithic sets of commands that carry out the same calculations every time they are executed. Instead, they adjust their behavior depending on the data supplied; on external…

Read More →

Function Return Values

A new feature introduced with Visual Basic 6 is that function return values aren’t limited to simple data types like Integers or Strings. Functions may now return ‘custom data types and even arrays. This is a new feature of the language, so we’ll explore it in depth and look at a few examples too. The ability of functions…

Read More →

Argument Passing Mechanisms

One of the most important procedural issues is the mechanism used to pass arguments. The examples so far have used the default mechanism: passing arguments by reference. The other mechanism is passing by value. Although most programmers use the default mechanism, it’. important to know the difference between the two mechanisms and when to use each one. Passing Arguments…

Read More →

Procedures

The one thing you should have learned about programming in Visual Basic so far that the application is made up of small, self-contained segments. Similarly, the code you write won’t be a monolithic listing. It will be made up of small segments called procedures and you will work on one procedure at a time. For example, when you write…

Read More →

Collections

Arrays are convenient for storing related data, but accessing individual elements can be a problem. To print the temperature in Atlanta, for instance, you would have to know the index that corresponds to Atlanta. If you didn’t, you would have to scan each element in the array until you found Atlanta. Ideally, arrays should be’ accessed by their contents.…

Read More →

Dynamic Arrays

Sometimes you may not know how large to make an array. Instead of making it large enough to hold the maximum number of data (which means that most of the array may be empty), you can declare a.dynamic array. The size of a dynamic array can vary during the course of the program. Or, you might need an…

Read More →

Multidimensional Arrays

One-dimensional arrays, such as those presented so far, are good for storing long sequences of one-dimensional data (such as names, and temperatures). But how would you store a list of cities and their average temperatures in an array? Or names and scores, years and profits, or data with more than two dimensions, such as products, prices, and units in…

Read More →

Arrays

A standard structure for storing data in any programming language is an array. ‘Whereas individual variables can hold single entities, such as a number, date, or string, arrays can hold sets of related data. An array has a name, as does a variable, and the values stored in it can be accessed by an index. For example, you…

Read More →

Back to Top