From: Jim Mack on
jim evans wrote:
> I use an ocx in a form, but I want to delete the ocx before the
> program ends. So, I unload the form and try to execute the
> instruction Kill My.ocx. But, I get an Error 424 "Object required"
> error. Is it impossible to delete an ocx that was used at any time
> in an app even if the form where it was used no longer exists?

Are you saying that you want to delete the file named MY.OCX ? That's
a bit unusual, so I wonder if that's really the case.

In any event, unloading a form doesn't entirely free it. You must 'set
[forminstance] = nothing' to complete the operation.

Even so, VB likely will hold onto any DLLs / OCXs it loads until the
process terminates. You'd probably need to find the module handle for
the OCX and call FreeLibrary on that before destroying the form.

--
Jim Mack
Twisted tees at http://www.cafepress.com/2050inc
"We sew confusion"

From: Bob Butler on

"jim evans" <jimsTAKEOUTnews2(a)houston.rr.com> wrote in message
news:1ivou51dssd6rk3cen9uoseoc8dklkv9di(a)4ax.com...
>I use an ocx in a form, but I want to delete the ocx before the
> program ends. So, I unload the form and try to execute the
> instruction Kill My.ocx. But, I get an Error 424 "Object required"
> error. Is it impossible to delete an ocx that was used at any time in
> an app even if the form where it was used no longer exists?

"object required" does not make any sense. Do you have "Option Explicit" at
the top of the module? I'm guessing you want
Kill "my.ocx" ' assuming the ocx is in the current directory
and not
Kill my.ocx
and that VB is complaining that "my" is not a valid object reference so it
can't query the OCX property.


From: Paul Clement on
On Thu, 13 May 2010 17:39:32 -0500, jim evans <jimsTAKEOUTnews2(a)houston.rr.com>
wrote:

� I use an ocx in a form, but I want to delete the ocx before the
� program ends. So, I unload the form and try to execute the
� instruction Kill My.ocx. But, I get an Error 424 "Object required"
� error. Is it impossible to delete an ocx that was used at any time in
� an app even if the form where it was used no longer exists?

I think your syntax is incorrect, perhaps missing double quotes enclosing the
file name?

Regarding component lifetime, it depends upon design and other factors:

http://msdn.microsoft.com/en-us/library/aa733719(VS.60).aspx

Paul
~~~~
Microsoft MVP (Visual Basic)
From: David Kaye on
jim evans <jimsTAKEOUTnews2(a)houston.rr.com> wrote:

>I use an ocx in a form, but I want to delete the ocx before the
>program ends.

Can you explain why you would want to do this? It sounds to me like you're
trying to run some kind of malware and want to eliminate the evidence before
anybody finds it. Suspicious...

From: Mayayana on
| >I use an ocx in a form, but I want to delete the ocx before the
| >program ends.
|
| Can you explain why you would want to do this? It sounds to me like
you're
| trying to run some kind of malware and want to eliminate the evidence
before
| anybody finds it. Suspicious...
|

You sure do have a suspcious mind. You said
the same thing recently when somone wanted to
send email without using Outlook automation.
I don't see anything to indicate there's anything
more than a misunderstanding going on. ...And if
he were up to no good, why would he tell you? :)


 | 
Pages: 1
Prev: String formatting question
Next: Followup