Late Binding syntax problem

D

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
 
K

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
 
H

Herfried K. Wagner [MVP]

Dean Slindee said:
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'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top