VB6 pass by value and pass by reference

This is a classic gotcha in VB6. It is explained in the VB6 manual. In this code below, VB6 treats the argument as an expression (Test) rather than a variable reference TestFunction (Test) In order to pass a reference to the variable either omit the brackets or use the legacy Call statement (which requires brackets) … Read more

Is there a need to set Objects to Nothing

VB uses a so-called “reference counting” garbage collector. Basically, the moment a variable goes out of scope, the reference counter on the referenced object is decremented. When you assign the object reference to another variable, the reference counter is incremented. When the counter reaches zero, the object is ready for garbage collection. The object resources … Read more

VBA array sort function?

Take a look here: Edit: The referenced source (allexperts.com) has since closed, but here are the relevant author comments: There are many algorithms available on the web for sorting. The most versatile and usually the quickest is the Quicksort algorithm. Below is a function for it. Call it simply by passing an array of values … Read more

Does VBA have Dictionary Structure?

Yes. Set a reference to MS Scripting runtime (‘Microsoft Scripting Runtime’). As per @regjo’s comment, go to Tools->References and tick the box for ‘Microsoft Scripting Runtime’. Create a dictionary instance using the code below: Set dict = CreateObject(“Scripting.Dictionary”) or Dim dict As New Scripting.Dictionary Example of use: If Not dict.Exists(key) Then dict.Add key, value End … Read more