Sometimes you want to be able to view trace messages when running your application outside the
VB IDE. Perhaps something slightly different happens as an Executable; or you may be running
something that's not so easy to debug, such as subclasses, callback procedures and custom COM
implementations. Whilst VB provides an App.LogEvent method which supposedly caters for this,
it isn't very good. This article provides an easy way to send debug messages to a remote
trace application for your viewing and logging pleasure.
Last Updated: 3 February 2003
The API Text Viewer provided with VB is a reasonable source of Win32 API call declares.
However, the Win32 API is continually expanding, and there aren't many (if any) updates to the
database of calls. Whilst MSDN Online provides you with most of the documentation you need
to implement a new call, there's normally one thing missing: which DLL will you find the
call in? For example, it isn't clear that the AlphaBlend function in the GDI section
is actually implemented in MSIMG32.DLL. This article describes how to find which DLL you
need using the Platform SDK and provides a search toy for doing it.
Last Updated: 14 January 2003
VB provides a simple Collection for storing objects. However, this object is internally implemented
as a hashed linked list, and as such provides good performance for access either by an item's key or
through enumeration. If you want to access an object by its index, however, you need to enumerate through
all the items until you reach the correct one, which is slow. This article presents an alternative collection
which is optimised for access by index, and, for large numbers of items, runs over 100x quicker than the VB
Last Updated: 2 January 2003
If you need to build a string by adding lots of pieces together, VB's string handling is slow
because a new string is created in memory every time a new piece is added. This article presents
a class which allocates a string chunk and then uses memory copy methods to manipulate the data
within the same string's memory. The result is a string class which can perform orders of magnitude
quicker than the equivalent VB code.
Last Updated: 1 January 2003
VB and COM makes a lot of things easy to do, particularly using and dealing with objects:
you just create them and normally they clear themselves up automatically once you're finished
with them. However, one side effect of the way COM works is that it is possible to create objects
which cannot terminate properly: this problem is known as a "Circular Reference".
The effects of a circular reference can range from using more memory than you ought to
(possibly to the extent that you get an Out Of Memory error) to much harsher effects
when you are experimenting with API calls.
Last Updated: 23 December 2002
LinkSpoof is a sample from Robert Heinig (email@example.com)
demonstrating one technique to take over the VB6 compile process in order to compile
your own code into the finished executable.
Last Updated: 15 November 1999
Every in-process component has a Base Address associated with it. When an application
loads the component, the Win32 DLL routines are invoked. Approximately speaking,
the component is placed in a memory location according to its Base Address.
If two components have the same base address, a conflict occurs, and time is wasted as
all the offsets within the second component are adjusted.
You can make things run quicker if you specify unique base addresses for your
components in advance.
Last Updated: 15 November 1999
Of course you're not supposed to allocate your own memory in Basic. Don't be so silly, what are you thinking of?
And you should stop using that CopyMemory call and certainly those pointers should not be there at all.
Just in case you're not feeling like any sort of Basic purist, this article is here to show you how to create little chunks of memory completely independently of variables or classes, how to access their contents, reallocate them and free them.
Just don't tell your boss that this is what you're doing...
Last Updated: 25 August 1999
ListBox and Combo boxes have an ItemData property to allow you to store an
additional long value against each ListItem. Similarly, ListView items and
TreeView nodes have a Tag property which can be used to store a string. But what if
you want to associate more data along with an item? Clearly you can make some use of
a long value to store a key, or use the bitfield technique to store multiple items.
With a string you can generate cunning schemes to store multiple strings and numbers
in the same string. But it would be a lot nicer if you could just store an object
against each item. Then data of any complexity can be stored against the item just by
setting the item data to point to the instance of the object.
This article explores three methods you can use to store objects using only a
long value to store the object, and hence you can associate the long value with either the
ItemData property of a List or Combo box, or (by using CStr and CLng) with the
Tag property of Microsoft control.
The uses don't stop there. You can replace VB's collection object with
an object that runs up to 100x faster. You could attach custom class data
to the items in an S-Grid control. Take advantage of the technique when building
controls directly from the API to store lots of data in the lParam member of the items...
this is great stuff!
Last Updated: 15 August 1999
Right. You are trying to create a control in VB, and your control has to catch the Tab key. It might be a grid,
where you would expect tab to move between cells, or it might be an editor control. This is not an unreasonable
request of any programming language which lets you create a control. Or is it? Want to go mad? You will if you try to intercept
Tabs properly in VB unless someone tells you the answer...
Last Updated: 20 February 1999