late binding error

  • Thread starter Thread starter Dean Slindee
  • Start date Start date
D

Dean Slindee

Is there any way to avoid the late binding error in this code snippet? Opton
Strict ON
Public Sub ComboBoxFlatClearForEdit(ByRef obj As Object)

Dim objControl As New Control

For Each objControl In obj.Controls ' (LATE BINDING ERROR)

ComboBoxFlatEmpty(objControl)

Next

End Sub



Thanks,

Dean Slindee
 
Dean Slindee said:
Is there any way to avoid the late binding error in this code snippet?
Opton
Strict ON
Public Sub ComboBoxFlatClearForEdit(ByRef obj As Object)

'ByRef obj As Object' => 'ByVal obj As Control'.
Dim objControl As New Control

Remove the 'As New Control', it doesn't make sense here.
 
Recoded as below and now is not a late bind. The change is to say "ByRef
obj As Control"
Public Sub ComboBoxFlatClearForEdit(ByRef obj As Control)

Dim ctl As New Control

For Each ctl In obj.Controls

ComboBoxFlatEmpty(ctl)

Next

End Sub
 
Back
Top