title: Is there a way to force the VB6 IDE to unload libraries?
body: <p>When debugging a VB6 application, I have noticed that the VB6 IDE keeps any libraries loaded if they were used by the application being debugged. The library remains loaded between debugging sessions. This interferes with my debugging because unfortunately, one of our libraries (written in delphi) keeps state around in global variables and has significant initialization/termination logic.</p>
  
  <p>Simplified example of the problem: I have a <code>foo.dll</code> with a counter inside it. I access this counter with the following declares in VB6:</p>
  
  <pre><code>Public Declare Function GetCounter Lib "foo.dll" () As Long
  Public Declare Function IncrementCounter Lib "foo.dll" () As Long
  </code></pre>
  
  <p>The problem in this case is that the counter is not reset when I start a new debugging session. I would rather not write application or library logic to take this "recycled library state" scenario into account. I want to be able to start a debugging session with a clean slate.</p>
  
  <p>Currently I force a library unload by restarting the VB6 IDE. Is there a better way?</p>
  
  <p><hr/>
  <strong>edit</strong>: I played around a bit with invoking kernel32.dll functions to unload/reload libaries from the immediate window; this turned out to only be a good way to crash the IDE or cause random behavior. I should have expected that as the IDE has no way of knowing that it's original handle for the library has become invalid.</p>
  
  <p>I have accepted AngryHacker's answer as I am now convinced that restarting vb6.exe is the only way to start a VB6 debugging session with a completely clean slate.</p>