Adelle Hartley <[EMAIL PROTECTED]> wrote:Hi Ivan,

> I need some help to handle an array of controls (label array,
> textbox array,etc)
> 
> create new elements & delete

You need to have one element on the form.  Set its "Index" property to 0,
that will make it the first element of an array.

In your form's code, you can add and remove elements by calling "Load" and
"Unload".

eg:

Load MyTextBox(1)
MyTextBox(1).Top = MyTextBox(0).Top + MyTextBox(0).Height
MyTextBox(1).Visible = True

Load MyTextBox(2)
MyTextBox(2).Top = MyTextBox(1).Top + MyTextBox(1).Height
MyTextBox(2).Visible = True

To save yourself from coding each element individually as above, you need to
add a member variable to the Declarations section of your form, to hold the
number of array elements:

  Private lmArrayElements As Long

and then create some functions to add and remove elements.  It is a good
idea to make the first element invisible because you cannot unload the 0th
element of the array:

Public Sub AddTextBox()
   lmArrayElements = lmArrayElements + 1
   If lmArrayElements = 1 Then
     'Don't need to load the 0th element because it was added
     'at design time - so just make it visible.
     MyTextBox(0).Visible = True
   Else
     Load MyTextBox(lmArrayElements - 1)
     'New control array elements need to be positioned, otherwise
     'they will occupy the same coordinates as the 0th element.
     MyTextBox(lmArrayElements - 1).Top = MyTextBox(lmArrayElements - 2).Top
+ MyTextBox(0).Height
     MyTextBox(lmArrayElements - 1).Visible = True
   End If
End Sub

Public Sub RemoveTextBox()
   If lmArrayElements < 1 Then
     Exit Sub
   End If

   If lmArrayElements = 1 Then
     'Can't unload the 0th element so just make it invisible.
     MyTextBox(0).Visible = False
   Else
     Unload MyTextBox(lmArrayElements - 1)
   End If
   lmArrayElements = lmArrayElements - 1
End Sub


HTH.

Adelle.





[Non-text portions of this message have been removed]


Yahoo! Groups SponsorADVERTISEMENT


---------------------------------
Yahoo! Groups Links

   To visit your group on the web, go to:
http://groups.yahoo.com/group/visualbasic6programming/
  
   To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
  
   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 



                
---------------------------------
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.

[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/k7folB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To reply to this message, go to:
    
http://groups.yahoo.com/group/visualbasic6programming/post?act=reply&messageNum=17793
    Please do not reply to this message via email. More information here:
    http://help.yahoo.com/help/us/groups/messages/messages-23.html

<*> To visit your group on the web, go to:  
    http://groups.yahoo.com/group/visualbasic6programming/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to