VB4 provides lots of new capabilities to use objects. Unfortunately,all of them require the object to be set beforehand, which isn’talways feasible. VB provides no way to see if an object has beenset. The only way of checking is to pass the object to a functionand attempt to access it. If it hasn’t been set, an error (number91) will occur.
Public Function IsSomething(o As _ Object) As LongDim j As Long Err.Clear On Error Resume Next If TypeOf o Is TextBox Then j = 1 'just a mindless test 'to see if we get an error End If If Err.Number = 91 Then 'error 91 = object not set IsSomething = False ElseIf Err.Number = 0 Then IsSomething = True Else Err.Raise Err.Number 'if some other error happened, raise it End If On Error GoTo 0End Function