Calling a method on a Object says "disallows late binding"
- by Maury Markowitz
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?