Language:EN
Pages: 2
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
the three numbers equate the argb for red

The three numbers equate the argb for red

604 CHAPTER 20

CREATING DOWNLOADABLE APPLICATIONS

Listing 20.1:

Creating a Built-in Component

Public Sub New(ByVal InitValue As Int32)
' Initialize the properties.

If (InitValue >= 0) And (InitValue <= 100) Then
_CompareValue = InitValue
Else
Throw New ArgumentOutOfRangeException( _
"InitValue", InitValue, _
"InitValue must be between 0 and 100")
End If
End Sub

CREATING STANDARD COMPONENTS 605

' Return a color based on the current value of _CompareValue.

If (_CompareValue >= 0) And (_CompareValue <= 33) Then

Return Colors.Green

End If

The Set portion of the property uses the same technique as the second constructor to change the _CompareValue value. Always check every input to reduce the risk of getting a bad input value.

The CalcColor() method doesn’t accept any input value. You could certainly create an override that would accept the comparison value as input. The method performs a numeric comparison and returns an enumerated color value based on the input. Using the technique shown reduces the risk of misinterpreting the method output.

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : Lucila Velasco

PageId: DOC30C5B36