0% found this document useful (0 votes)
23 views1 page

VB.NET Color Structure Guide

Uploaded by

khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views1 page

VB.NET Color Structure Guide

Uploaded by

khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Structure Behavior

Get
Return colorDefault
End Get
End Property

Public WriteOnly Property SetUserDefined(ByVal red As Integer, _


ByVal green As Integer, ByVal blue As Integer) As Color
Set(ByVal Value As Color)
Value = Color.FromArgb(red, green, blue)
End Set
End Property
End Structure

You could then use the Color structure as follows:

Dim Col As New GridColors()


CommCon.BackColor = Col.UserDefined()

or

Dim Col As New GridColors(200,255,30)


CommCon.BackColor = Col.UserDefined()

or

Dim Col As New GridColors()


CommCon.BackColor = Col.grLightGray

As shown in the above code, structures are useful for returning related pieces of information about a data type.
Instead of declaring a new variable for each color in the example, we simple declare a structure and change
the color it represents by changing one of its member properties. Once you declare the structure it becomes a
standard value type that can be referenced like any of the built−in data types.

Note The code for the GridColors structure is the Palette project in the Vb7cr solution.

Structure Behavior

The structure is an extremely efficient and flexible construct. The following behaviors of structures provide
the flexibility to use them in a variety of applications and algorithms.

Nested Structures

In nested structures, you can declare and implement one or more structures inside another one as shown in the
following code:

Public Structure GridColors '


Private colorDefault As Color
'. . .

Private Structure Hue


Dim defaultHue As Integer
'...
End Structure
End Structure

246

You might also like