Search
Left Quote    I start where the last man left off.
- Thomas A. Edison    
Right Quote
 
[login] | [Register]
 

Getting Started with VB 6.0

by: bs0d
Page: 8 of 9
(View All)

Control Arrays, Scroll Bars and RGB Function



Array - A group of data items that are referred to by the same name.
Control Array - A group of controls sharing the same name and event procedures.
Index - A variable used to refer to each element in the control array.

Control Arrays can be used with the following controls:

  • Text Boxes
  • Option Buttons
  • Check Boxes
  • Labels
  • Command Buttons

Control Arrays are most commonly used with text boxes and option buttons.

CREATING A CONTROL ARRAY:



  1. Drop a control on the form and assign it a name.
  2. Drop a second control on the form and assign it the SAME name.
  3. You will be given a message indicating that you already have a control named "whatever" and asks you if you want to create a control array.
  4. Press "Yes" and this will create your control array.
  5. Now, for each subsequent item added, give it the same name also.
  6. Once you create the control array, each item within the array will have an index. The first will be an index of 0, second of 1, third of 2 and so on...


Example Control Array using a Select Case:

This example is if you had six option buttons with names of colors and a Rounded Square shape that will fill the color of the selected option button.




SUM AND AVERAGE OF TEST SCORES USING CONTROL ARRAYS:



Here is another example of a control array. This will be if you wanted to figure the sum and average of test scores.




Scroll Bars and RGB Function



Scroll Bar - A control that allows you to see hidden information on the screen. This information can be text, icons or controls.

In VB a scroll bar is used to represent a range of values. Scroll bars are also used to control sound level, color, size and other values that can be changed in small amounts or large increments.

Scroll Box - The little square, which appears inside the scroll bar. Pressing down on the scroll box changes the value property of the scroll bar. Another name for the scroll box is the thumb.


PROPERTIES OF THE SCROLL BAR:


  • Min - The smallest value the scroll bar can take on
  • Max - The largest value the scroll bar can take on
  • Small Change - The distance to move when the user clicks on the scroll arrows
  • Large Change - The distance to move when the user clicks on the gray area of the scroll bar
  • Value - Indicates the current position of the scroll bar and its corresponding value within the scroll bar.

TYPES OF SCROLL BARS:



  • Vertical Scroll Bar - Begins with the prefix "vsb"
  • Horizontal Scroll Bar - Begins with a prefix "hsb"

EVENTS OF THE SCROLL BAR:



Change Event - Occurs when the user clicks on the gray area of the scroll bar.
Scroll Event - Occurs when the user drags the scroll box.

As soon as the user releases the mouse botton, the scroll event ceases and a change event occurs. When you write code for the scroll bar, you will want to write code for both Change even and the Scroll event.


SAMPLE PROGRAM USING HORIZONTAL SCROLL BAR:




SAMPLE PROGRAM USING VERTICAL SCROLL BAR:




RGB FUNCTION



The RGB function specifies the quantities of red, green and blue for a large variety of colors. The value for each color ranges from 0 to 255 with 0 being the least intense and 255 being the most intense. The color arguments are in the same order as their letters in the function name, red first, then green and then finally blue. You can use the RGB function to assign the color to a property or specify the color in a graphics method.


Chosen_Color = RGB(RedValue, GreenValue,BlueValue)

Examples:




1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |  9  |  
Next »


No Comments for this page.

You Must be logged in or a member to comment.


Tutorial Stats

Tutorial Stats

164,769 Views
0 Total Comments
4.16 Rating of 5 (6 Votes)

Options

Tutorial Options

· Login to Rate This Article
· Login to Post a Comment
· Read more by this author
Digg This Article! Del.icio.us: Bookmark This Article Reddit: Bookmark This Article BlinkList: Blink This Article! YahooMyWeb BlogMarks: Add This Mark! Furl: Save This Article Spurl: Mark This Article

Articles

Related    

· Coding a Webserver
· Using Crystal Reports in VB
Your Article Here



"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank