late binding error

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
 
H

Herfried K. Wagner [MVP]

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.
 
D

Dean Slindee

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
 

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