If you just want to manage these controls by name, and then use a collection or set collection can, for example:
Dim myControls as new Dictionary
Then if not myControls. The exists (controlName)
MyControls. Add controlName, new Dictionary
End the if
MyControls (controlName). Add controlIndex, Controls. The add (mandButton "VB.Com", "MyButton" & amp; CStr (I))
Since then, you can use myControls (controlName) (contrlIndex) to access what you add any controls
CodePudding user response:
Members of the general Dictionary is a Dictionary, is a key/value pair (string key, Object value), so can the key index, can also according to the index index; Collection is the Collection, the member is an Object, can only according to the index index,Control array usage scenario is "population control", such as a pile of buttion, I can only write an event, for each button of the same event without having to write a code, it only provides some scenario implementation requirements more convenient method, is not must be used, nor must not use, like 1 + 8=9, 2 + 7=9, 1 + 8 also is not the only solution,
Command1 this button, if you want to get form directly with me. Controls (" Command1 "), and use the same dictionary?
CodePudding user response: