Home All Groups Group Topic Archive Search About

Late Binding syntax problem

Author
8 Jan 2006 5:05 PM
Dean Slindee
The DirectCast below is a syntax error.  Anyone know how to write it to do
the same as the statement above it which works when Option Strict Off?

Dim ctlArray As ArrayList)

Dim typ As String

typ = ctlArray(int).GetType.ToString

Select Case typ

Case "System.Windows.Forms.CheckBox"

ctlArray(int).Checked = False

'DirectCast(ctlArray(int), Control).Checked = False

End Select

Next

Author
8 Jan 2006 5:21 PM
Ken Tucker [MVP]
Hi,

        You should directcast to checkbox not control.

        Dim c As Control

        c = New CheckBox
        Dim t As Type = c.GetType
        Select Case t.ToString
            Case "System.Windows.Forms.CheckBox"
                DirectCast(c, CheckBox).Checked = False
        End Select


Ken
------------------------------
Show quoteHide quote
"Dean Slindee" <slin***@charter.net> wrote in message
news:fGbwf.19$gN1.1@fe05.lga...
> The DirectCast below is a syntax error.  Anyone know how to write it to do
> the same as the statement above it which works when Option Strict Off?
>
> Dim ctlArray As ArrayList)
>
> Dim typ As String
>
> typ = ctlArray(int).GetType.ToString
>
> Select Case typ
>
> Case "System.Windows.Forms.CheckBox"
>
> ctlArray(int).Checked = False
>
> 'DirectCast(ctlArray(int), Control).Checked = False
>
> End Select
>
> Next
>
>
Author
8 Jan 2006 5:39 PM
Herfried K. Wagner [MVP]
"Dean Slindee" <slin***@charter.net> schrieb:
> The DirectCast below is a syntax error.  Anyone know how to write it to do
> the same as the statement above it which works when Option Strict Off?
>[...]
> 'DirectCast(ctlArray(int), Control).Checked = False

'DirectCast(..., CheckBox).Checked = False'.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>