Well, sorry I don't have a complete solution, just a suggestion.
Maybe you could use the CreateControl method in a loop. This way you can easily set the properties of the controls, especially their names and the on_lost_focus event, which you set to your 'Stock Value SubTotals'-function.
Think...