Results 1 to 7 of 7

Thread: Control Type

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    That's strange. I don't get any errors like that. Here's what I did to try it out.

    Start a new standard EXE project. Add one checkbox and set its index property to 0 (zero). Add a command button to the form and put the following codde in its click event:
    Code:
    Private Sub Command1_Click()
        Dim X As Variant
        Dim iCount As Integer
    
        Set X = Check1
        iCount = X.Count
        Load X(iCount)
        With X(iCount)
            .Move .Left, X(iCount - 1).Top + .Height
            .Visible = True
        End With
    End Sub
    Now, every time you click on the CommandButton it load an other CheckBox.

    Best regards

  2. #2

    Thread Starter
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Originally posted by kedaman
    The count is a property of a collection object so i guess you have to delclare x as a collection, and add your contols in it
    A control array is actually equal to a control collection. You can use the For Each Next syntax on it. The difference is that it can start with any index and it doesn't have a Remove method.

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Another diff is that you can't access the properties from a list, i think the contol arrays are classcollections
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363

    Wink

    That works...just need to figure out what I was doing differently. Thanks Joacim!
    Wade

  5. #5
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363
    I realized what's different. Try using your same code but alter the
    Code:
    Set X = Check1
    Try using:
    Code:
    'In the Checkbox
    Set X = ActiveControl
    Msgbox X.Count 'Gives error 438: object doesn't support this property or method
    or:
    Code:
    'In the command button
    For each X in Controls
       If X.Name = "Check1" Then
          Msgbox X.Count 'Gives error 438: object doesn't support this property or method
       End If
    I need a modular set statement. What can I do to make the set statement dynamic?

    Thanks.
    Wade

  6. #6

    Thread Starter
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Could this be of any help then?
    Code:
    If ActiveControl.Name = "Check1" Then
        Set X = Check1
        MsgBox X.Count
    Else
        Set X = ActiveControl
    End If

  7. #7
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    363
    Thanks for the replies. It's close but I don't want to hard-code Check1 in the set statement. I can read "Check1" from a file or database field, so I'm trying to make this dynamic. Any other ideas?
    Wade

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