QBColor Function VB.NET

Class
Microsoft.VisualBasic.Information

Syntax
QBColor(color)

Return Value
Long

Description
Returns a Long integer representing the RGB system color code

Rules at a Glance
color can have any of the following values:

TABLE

TABLETABLE

Programming Tips and Gotchas

  • The RGB function allows much more flexibility than the older QBColor function, which is a remnant of QBasic.
  • Visual Basic now contains a wide range of intrinsic color constants that can be used to assign colors directly to color properties of objects.

Queue Class

Namespace
System.Collections

Createable
Yes

Syntax
Dim queuevariable As [New] Queue

Description
A Queue object is a model of a queue. Succinctly put, a queue is a first-in, first-out data structure. (This is often abbreviated FIFO.) Put another way, a queue is a data structure that models a line of items. There is a method for inserting items at the end of the line (enqueueing), as well as a method for removing the item that is currently at the front of the line (dequeueing). Under this scenario, the next item to be dequeued is the item that was placed in line first—hence the term first-in, first-out.
Note that the elements in a Queue object are of type Object. Queue class members marked with a plus sign (+) are discussed in detail in their own entries.

Public Shared Method
Synchronized

Public Instance Properties
Count +
IsReadOnly
IsSynchronized
SyncRoot

Public Instance Methods
Clone
Contains +
CopyTo +
Dequeue +
Enqueue +
Equals
GetEnumerator
GetHashCode
GetType
Peek +
ToArray +
ToString

Example
Here is a bit of code to illustrate the members of the Queue class:

VB .NET/VB 6 Differences
The Queue object is new to the .NET Framework.

Queue.Clear Method

Class
System.Collections.Queue

Syntax
queuevariable.Clear( )

Return Value
None

Description
Removes all entries from the queue

Queue.Contains Method

Class
System.Collections.Queue

Syntax
queuevariable.Contains(obj)

Return Value
Boolean (True or False) indicating whether obj is found in the queue

Description
Returns a Boolean indicating whether a given element whose value is obj is somewhere in the queue

Rules at a Glance

  • obj must correspond exactly to an item in the queue for the method to return True.
  • The method searches the queue sequentially. In other words, its performance is inversely proportional to the number of items in the queue.

Programming Tips and Gotchas
In comparing objects in the queue with obj, the Contains method in turn calls the BCL's Object.Equalsmethod to perform the comparison. The Equals method returns True if two object instances are the same instance.

Queue.CopyTo Method

Class
System.Collections.Queue

Syntax
queuevariable.CopyTo(array, index)

The index of the first array element to receive an element of the queue

Return Value
None

Description
Copies the queue elements into an array, starting at a specified array index

Rules at a Glance

  • The array can be of any data type that is compatible with the queue elements. Thus, for instance, we cannot use an Integer array to hold queue elements that are strings (that is, Objects whose subtype is String).
  • The array must be sized to accommodate the elements of the queue prior to calling the CopyTo method.

Example

Queue.Count Property

Class
System.Collections.Queue

Syntax
queuevariable.Count( )

Return Value
Integer

Description
This read-only property returns an Integer specifying the number of elements in the queue.

Queue.Dequeue Method

Class
System.Collections.Queue

Syntax
queuevariable.Dequeue( )

Return Value
Object

Description
Removes the first item from the queue and returns it as an Object

Rules at a Glance

  • Dequeue removes the item at the beginning of the queue and decrements the Count property by one.
  • The Dequeue method generates an error if applied to an empty queue. Thus, it may be advisable to check for an empty queue using the Count property before attempting to dequeue.

Programming Tips and Gotchas
Dequeue is similar to the Peek method. The Peek method returns a reference to the object at the beginning of the queue, but unlike the Dequeue method, does not remove it from the queue.

Queue.Enqueue Method

Class
System.Collections.Queue

Syntax
queuevariable.Enqueue(obj)

Return Value
None

Description
Places an object at the end of the queue

Rules at a Glance
Enqueue adds an item to the end of the queue and increases the Count property by 1.

Queue.Peek Method

Class
System.Collections.Queue

Syntax
queuevariable.Peek( )

Return Value
Object

Description
Returns the first item in the queue as an Object, but does not remove it from the queue

Programming Tips and Gotchas
The Peek method is similar to the Queue object's Dequeue method, except that it leaves the queue intact.

Queue.ToArray Method

Class
System.Collections.Queue

Syntax
queuevariable.ToArray( )

Return Value
An Array of type Object

Description
This method creates an array of type Object, copies the elements of the queue—in order—to that array, and then returns the array.

Programming Tips and Gotchas
Unlike the CopyTo method, we do not need to define an array in advance. However, we cannot specify the starting array index for the copy procedure using ToArray.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

VB.NET Topics