Sometimes a lot of "Old School" technology seems to pop up all at once. It's Tuesday and already I've worked on two old school issues. Here's what I told them and learned myself:
From a user's point of view, there are two implementations of ActiveX technology in Internet Explorer: ActiveX Controls (created with an <object> tag in an HTML page) and ActiveX Documents (created when IE sees a mime/type that is handled by an registered application.)
When you open up a Word Document or a Adobe PDF and it appears INSIDE Internet Explorer that is an "ActiveX Document." When you open up an HTML page that contains en <embed> or <object> tag that is an "ActiveX Control."
Both of these technologies, along with "Authenticode" (when a dialog pops up and warns you about downloading code, do you trust, etc.) are collectively, to the layman, "ActiveX."
When you turn off ActiveX in the IE Tools|Options|Security you are affecting ActiveX Documents as well. If you click on a PDF and try to open it in IE, you'll likely get a blank page or a "broken window" graphic. You'll be unable to View|Source because there is no HTML source to view!
In VB6, what is the difference SPECIFICIALLY between:
Dim oCalcutta As FooBar Set oCalcutta = New FooBar
and
Dim oCalcutta As New FooBar
Is there a speed difference? (there doesnt appear to be a major one) COM difference? (are internals handled differently?)
Turns out there is a difference. (Thanks to Stephen Forte, Francesco Balena, Ralf Westphal, and especially Henrik Nielsen)
When you write code like this:
Dim obj As New Class1 obj.Method
Then each reference to a member such as:
obj.Method
will be compiled to the following code (pseudo-code):
If obj Is Nothing Then Set obj = New Class1 End If obj.Method
This of course implies a certain performance hit but I wouldnt expect it to be in any way significant.
Much more important (in my opinion) is the difference in semantics (which follows from the above) between the two constructions:
Dim obj As Class1 Set obj = New Class1 Set obj = Nothing obj.Method
Dim obj As New Class1 Set obj = Nothing obj.Method
The first construction will result in a run-time error (Object variable or With block variable no set) and the second will not.
UPDATE: Some wisdom from Dan Appleman. "The reason [you're told] not to use [a Dim on one line] is that this can result in subtle bugs - especially during cleanup - when you are either accidentally recreating objects you think you cleaned up, or are referencing new objects when you accidentally cleared old ones."
Scott at DevReach in Bulgaria in October
Developer Stand up Comedy - Coding 4 Fun
TechDays/DevDays Netherlands and Belgium:
Posts by Category Posts by Month
Greatest Hits Dev Tools List