Late binding; call could fail at run time.

  • Thread starter Thread starter tm
  • Start date Start date
T

tm

I have created a collection as follows:

Public pPrintMonthColl As Collection = New Collection

pPrintMonthColl.Add(checkBox1)
pPrintMonthColl.Add(checkBox2)
pPrintMonthColl.Add(checkBox2)

Now when I try to access a control in the collection as follows:

pPrintMonthColl(2).Checked = True

I receive the following error message:

Late binding; call could fail at run time.

How can I correct this?

tm
 
tm said:
I have created a collection as follows:

Public pPrintMonthColl As Collection = New Collection

pPrintMonthColl.Add(checkBox1)
pPrintMonthColl.Add(checkBox2)
pPrintMonthColl.Add(checkBox2)

Now when I try to access a control in the collection as follows:

pPrintMonthColl(2).Checked = True

I receive the following error message:

Late binding; call could fail at run time.

How can I correct this?

tm

directcast(pPrintMonthColl(2), checkbox).Checked = True

Chris
 
tm,

By not using late binding.

Late binding can be used if you are converting a program from VB6 to VB.Net,
in all other situations set in top of your program "Option Strict On" or set
that in the standard options. (I have done that and set if I want a program
with late binding in top of my program "Option Strict Off". Which I don't
have :-)

I hope this helps,

Cor
 
Back
Top