Home All Groups Group Topic Archive Search About

Late binding; call could fail at run time.

Author
12 Feb 2006 11:15 PM
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

Author
13 Feb 2006 1:26 AM
Chris
tm wrote:
Show quoteHide quote
> 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
Author
13 Feb 2006 7:23 AM
Cor Ligthert [MVP]
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