PC Review


Reply
Thread Tools Rate Thread

How to avoid late binding??

 
 
active
Guest
Posts: n/a
 
      14th Feb 2007
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


 
Reply With Quote
 
 
 
 
Chris Dunaway
Guest
Posts: n/a
 
      14th Feb 2007
On Feb 14, 2:25 pm, " active" <activeNOS...@a-znet.com> wrote:
> 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


 
Reply With Quote
 
active
Guest
Posts: n/a
 
      14th Feb 2007
Couldn't be better

thanks

"Chris Dunaway" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Feb 14, 2:25 pm, " active" <activeNOS...@a-znet.com> wrote:
>> 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
>
>



 
Reply With Quote
 
Phill W.
Guest
Posts: n/a
 
      15th Feb 2007
active wrote:

> 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.
 
Reply With Quote
 
active
Guest
Posts: n/a
 
      15th Feb 2007
I haven't got myself to code that way.

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


Thanks

"Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-k> wrote in message
news:er1u28$t9f$(E-Mail Removed)...
> active wrote:
>
>> 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.



 
Reply With Quote
 
Lloyd Sheen
Guest
Posts: n/a
 
      15th Feb 2007
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
" active" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I haven't got myself to code that way.
>
> If I did, what would happen - the compiler force me to add DirectCast?
>
>
> Thanks
>
> "Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-k> wrote in message
> news:er1u28$t9f$(E-Mail Removed)...
>> active wrote:
>>
>>> 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.

>
>


 
Reply With Quote
 
active
Guest
Posts: n/a
 
      15th Feb 2007
thanks

"Lloyd Sheen" <(E-Mail Removed)> wrote in message
news:C2B13307-1886-4D45-9BB1-(E-Mail Removed)...
> 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
> " active" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I haven't got myself to code that way.
>>
>> If I did, what would happen - the compiler force me to add DirectCast?
>>
>>
>> Thanks
>>
>> "Phill W." <p-.-a-.-w-a-r-d-@-o-p-e-n-.-a-c-.-u-k> wrote in message
>> news:er1u28$t9f$(E-Mail Removed)...
>>> active wrote:
>>>
>>>> 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.

>>
>>

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel interop - how to avoid late binding? GS Microsoft VB .NET 2 16th Jun 2007 05:28 PM
>> Early binding and late binding with attachment =?Utf-8?B?Sm9uYXRoYW4=?= Microsoft Outlook VBA Programming 2 9th Jun 2006 02:24 AM
Late Binding examples of binding excel application =?Utf-8?B?SGVhdGhlck8=?= Microsoft Excel Programming 14 17th Mar 2005 08:19 AM
how to avoid late binding =?Utf-8?B?VGhvbWFzIE3DvGxsZXItTHluY2g=?= Microsoft ASP .NET 3 2nd Feb 2004 07:08 PM
How to avoid Late Binding William Ryan Microsoft Dot NET 5 16th Sep 2003 08:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:37 PM.