Visual Basic 6 Internal Event Handling

VB6 calls control events in a very specific way. It’s impressive but the design of event handling results in losing a certain number of guaranteed bytes per control used. By losing bytes, I am referring to the addition of redundant bytes in the executable code.

I studied the entire structure with Disassemblers and debuggers and found out that the total number of redundant bytes is governed by the following formula:

where:N = Total Number of Controls UsedNumber_Of_Events = Total Number Events Supported by a Control (Different for each control)Events_Used = Number of Events Used for each control.

So Imagine a simple form having two text boxes and 1 command button for a simple login box, considering that only the following events are used:Form_Load()
Command1_Click()
The Total number of Redundant Bytes is:
(4*(31+6-1)) + 2*(4*(24+6)) + (4*(17+6-1)) = 472
1 FORM + 2 TEXT BOXES + 1 CMD BTN

That’s 472 unnecessary bytes just for a simple login box using absolutely no user-written code.