Calling a method on a Object says "disallows late binding"

Posted by Maury Markowitz on Stack Overflow See other posts from Stack Overflow or by Maury Markowitz
Published on 2014-06-11T15:13:01Z Indexed on 2014/06/11 15:24 UTC
Read the original article Hit count: 161

Filed under:
|

I have a calls called DtaDate that stores an integer "key", a string name, a string for the date, and a Date object that is created from that string.

I have some code that needs to accept a date-like object. I'd like the user to be able to pass in anything date like - a Date object which I'll extract the information from, another DtaDate, a string with the date in it, or even the key, which I'll use to look up the DtaDate from a collection.

So I have this:

    Friend Sub New(NameIn As String, DateFormulaIn As String, Optional FromDateIn As Object = Nothing)
[stuff that works]
[check that we got a FromDateIn...]
            If TypeOf FromDateIn Is DtaDate Then
                fdk = FromDateIn.Key
                Ans.FromDate = fdk

VB tells me that "Option Strict On disallows late binding". The other cases, where a string or integer is the TypeOf, I use CInt or CStr. But this is the first time I've actually run into a case where the casting is a non-base type. What's the trick?

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about casting