A

A


Back to Index

Add Controls at Runtime

This one comes up a lot in the groups.. Here's a sample of 2 ways to add controls at runtime using Controls.Add and Load.

Add Controls at Runtime With Events (kind of) Updated 2008-09-04

VB6 Only! This one also comes up a lot in the groups. Normally, if you want events from controls that you've added using Controls.Add, you need to declare an object variable for each control and use WithEvents to enable event trapping. This problem makes dealing with unknown numbers of controls almost impossible. This sample provides a way to get events from any number of controls added at runtime and also shows some basic Implements keyword usage. I've seen several samples that use class modules that trap control events and process them but not very many samples that send information to the form as well. As coded, this sample supports Command Buttons, ComboBoxes and Text Boxes only but contains comments and straight forward code to help you add any type of control. Note that this doesn't replace VB5/6's Load functionality, it only enhances VB6's Controls.Add functionality. Load is still the preferred method of loading an unknown number of controls at runtime.

Automatically Switch Tabs (SSTab)

Here's a way to automatically go to the first control on the next tab if the Tab key is pressed while in the last control on each tab and, go to the last control on the previous tab if Shift-Tab is pressed while in the first control on each tab. (whew...) The zip contains 2 forms. Form1 shows only the Tab/Shift-Tab code while Form2 shows that plus a routine that selects all text in a textbox when it gets focus... only if the keyboard was used (not the mouse... IMO, the way it should be) Note that this is an updated version of the sample I have posted on VBCity.com.

Back to Index

A B C D E F G h I j k L M N O P q R S T U V w x y z