Question,
[quoted text, click to view] > I keep getting the gollowing warning on the line
>
> Select Case C.borderstyle
>
> Operands of type Object used in expressions for 'Select', 'Case'
> statements; runtime errors could occur.
>
> How come
The operand could be *any* object including an object that does not support
a BorderStyle property, consider using the actual type of parameter
expected, in this case Control.
It appears that you are attempting to calculate the border width of
controls. Rather then hard code the information I would suggest you use
SystemInformation instead:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.systeminformation.aspx Something like:
[quoted text, click to view] > Function GetRoot(ByVal C As Control, ByRef oX As Integer, ByRef oY As
> Integer) As Control
> Try
> If Not IsNothing(C.BackgroundImage) Then Return C
> If C.BackColor.ToString = Color.Transparent.ToString Then
> oX += C.Left
> oY += C.Top
> Try
> Select Case C.borderstyle
> Case BorderStyle.FixedSingle
oX += SystemInformation.Border3DSize.X
oY += SystemInformation.Border3DSize.Y
[quoted text, click to view] > Case BorderStyle.Fixed3D
oX += SystemInformation.BorderSize.X
oY += SystemInformation.BorderSize.Y
[quoted text, click to view] > End Select
> Catch
>
> End Try
>
> C = GetRoot(C.Parent, oX, oY)
> End If
> Catch ex As Exception
> End Try
> Return C
> End Function
I would actually consider passing a single Point or Size parameter rather
then X & Y parameters
[quoted text, click to view] > Function GetRoot(ByVal C As Control, ByRef position As Point) As Control
or
[quoted text, click to view] > Function GetRoot(ByVal C As Control, ByRef size As Size) As Control
Depending on what the expected usage of the X & Y return values are.
Also using .NET 2.0 (VS 2005) you can use operator overloading on the Point
& Size variables:
position += SystemInformation.Border3DSize
size += SystemInformation.Border3DSize
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net [quoted text, click to view] <Question@aol.com> wrote in message
news:fjgkp2hfio56ujelphj9e23ko9hul65bmd@4ax.com...
>I have the follwoing code That I copy from the Internet
>
> Function GetRoot(ByVal C As Object, ByRef oX As Integer, ByRef oY As
> Integer) As Control
> Try
> If Not IsNothing(C.BackgroundImage) Then Return C
> If C.BackColor.ToString = Color.Transparent.ToString Then
> oX += C.Left
> oY += C.Top
> Try
> Select Case C.borderstyle
> Case BorderStyle.FixedSingle
> oX += 1
> oY += 1
> Case BorderStyle.Fixed3D
> oX += 2
> oY += 2
>
> End Select
> Catch
>
> End Try
>
> C = GetRoot(C.Parent, oX, oY)
> End If
> Catch ex As Exception
> End Try
> Return C
> End Function
>
> I keep getting the gollowing warning on the line
>
> Select Case C.borderstyle
>
> Operands of type Object used in expressions for 'Select', 'Case'
> statements; runtime errors could occur.
>
> How come
>