Microsoft Visual Basic 2010 Step by Step eBook

(Tina Meador) #1

290 Part II Programming Fundamentals


This form looks similar to the earlier projects in this chapter and features a test box
for displaying array data. However, it also contains three buttons for manipulating
large arrays and a progress bar object that gives the user feedback during longer
array operations. (Visual feedback is useful when computations take longer than a few
seconds to complete, and if you use this code to sort an array of 3,000 array elements,
a slight delay is inevitable .)


  1. Click the progress bar on the form.


The ProgressBar1 object is selected on the form and is listed in the Properties window.
I created the progress bar object by using the ProgressBar control on the Common
Controls tab in the Toolbox. A progress bar is designed to display the progress of
a computation by displaying an appropriate number of colored rectangles arranged
in a horizontal progress bar. When the computation is complete, the bar is filled with
rectangles. (In Windows 7 and Windows Vista, a smoothing effect is applied so that
the progress bar is gradually filled with a solid band of color—an especially attractive
effect .) You’ve probably seen the progress bar many times while you downloaded files
or installed programs within Windows. Now you can create one in your own programs!
The important properties that make a progress bar work are the Minimum, Maximum,
and Value properties, and these are typically manipulated using program code. (The
other progress bar properties, which you can examine in the Properties window, control
how the progress bar looks and functions .) You can examine how the Minimum and
Maximum properties are set by looking at this program’s Form1_Load event procedure.


  1. Double-click the form to display the Form1_Load event procedure.


You see the following code:
Free download pdf