Home > Software engineering >  Dim myControls as new Dictionary shows undefined user types
Dim myControls as new Dictionary shows undefined user types

Time:09-19

Now that is dynamically join control, why still need to use the control array?
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:

refer to the original poster qq_34497259 response:
now that is dynamically join control, why still need to use the control array?
if you just want to manage these controls by name , 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))

After that, you can use myControls (controlName) (contrlIndex) to access what you add any one control

How many people use controls "array", in order to this!!!!!!
I think this kind of "demand" is almost close to zero, and the control array is not the main purpose of graces,

It seems the building doesn't understand the "planning" of software engineering,
Send a post, also irrelevant...

  • Related