Catching a error in a custom property.

vis781

Well-known member
Joined
Aug 30, 2005
Messages
2,016
Location
Cambridge, UK
Programming Experience
5-10
Hi there, i'll try to explain this as simply as possible.

I have a public property in my user control tha allows the user to adjust the opacity of a color. It is adjusted by altering the alpha channel. However if i get a daft user and he/she tries to set it at less that one or more than 255 the application throws a wobbly despite any error handling that i place in there. Can any one help as to where i should place my error handling so the error is delt with by my code. My code it as follows:

[Public property GradientOpacity as Integer

Get
Return some variable
End Get

Try
Set (ByVal value as Integer)
some variable = value

Catch ex as exception

Throw new ArgumentOutOfRangeException

End Set
End Try

If you can help i would appreciate it. Thanks
 
Thanks for the tip. I must admit i've never used delegates before, atleast not knowingly. And after i read the info on the link you gave me i'm still none the wiser. Looks like it'll be a while till i get my head round this one. But thanks again.
 
Back
Top