How to avoid late binding??

  • Thread starter Thread starter active
  • Start date Start date
A

active

Me is a combobox and the items are objects with a property "String1"

The problem with the following construct is that one does not know if there
is a typo until run time.

Me.Items(LpCnt).string1



What is the best way to force early binding or at least get the compiler to
check?



Thanks
 
Me is a combobox and the items are objects with a property "String1"

The problem with the following construct is that one does not know if there
is a typo until run time.

Me.Items(LpCnt).string1

What is the best way to force early binding or at least get the compiler to
check?

Thanks

DirectCast(Me.Items(LpCnt), MyClass).String1
 
active said:
The problem with the following construct is that one does not know if there
is a typo until run time.

Me.Items(LpCnt).string1
What is the best way to force early binding or at least get the compiler to
check?

Option Strict On

Regards,
Phill W.
 
I haven't got myself to code that way.

If I did, what would happen - the compiler force me to add DirectCast?


Thanks
 
Unless you have a base object which contains most of the methods you are
using you are correct.

But remember, it will take you a second to do this and over the period of
use of the appication it will save you client much time. Also you will get
many less runtime errors since the code has been checked at compile time.

Lloyd Sheen
 
thanks

Lloyd Sheen said:
Unless you have a base object which contains most of the methods you are
using you are correct.

But remember, it will take you a second to do this and over the period of
use of the appication it will save you client much time. Also you will
get many less runtime errors since the code has been checked at compile
time.

Lloyd Sheen
 
Back
Top