Results 1 to 3 of 3

Thread: Control Array

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    Cleveland,Oh
    Posts
    95

    Control Array

    Hi All:
    Can someone show me how to find out if certain object is loaded in the control array. I have a form and that form will have varried number of comboboxes and textboxes depending on what selection the user has made. I need to loop through the control array and if the combobox is loaded remove that combobox or textbox from the control array. I am not sure how to go about do this. I need help.

    Thanks
    Zus

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132
    Something like this will do the job but you'll have to modify it if you need to re-arrange controls:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     UnloadControl "Text1", 2, False
    5. End Sub
    6.  
    7. Public Sub UnloadControl(sName As String, iIndex As Integer, bCombo As Boolean)
    8. Dim ctl As Control
    9.  
    10.     For Each ctl In Me.Controls
    11.         If bCombo Then
    12.             If TypeOf ctl Is ComboBox Then
    13.                 If LCase(ctl.Name) = LCase(sName) And ctl.Index = iIndex Then
    14.                     Unload ctl
    15.                     Exit For
    16.                 End If
    17.             End If
    18.         Else
    19.             If TypeOf ctl Is TextBox Then
    20.                 If LCase(ctl.Name) = LCase(sName) And ctl.Index = iIndex Then
    21.                     Unload ctl
    22.                     Exit For
    23.                 End If
    24.             End If
    25.         End If
    26.     Next ctl
    27.  
    28. End Sub
    NOTE: you cannot unload any control that was created during design time.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    Cleveland,Oh
    Posts
    95

    Control array

    Thanks RhinoBull!!
    Zus

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width