Results 1 to 8 of 8

Thread: control Array

  1. #1

    Thread Starter
    Hyperactive Member badgers's Avatar
    Join Date
    Sep 1999
    Location
    Madison, WI USA
    Posts
    444
    we have a new person here who did the User interface work.
    This work, consists of 151 or so check boxes and labels.
    these are setup in a control array.

    Here is the problem

    I loop through the array.
    The person doing the user interface deleted some labels and created new ones.

    I get an error that element 15, or 26, or 48, or 73, or 89, or 91, or 108, or 141 does not exist.
    is there anyway to get VB to reassign the array numbers? I don't care what the order is, I just need consecutive numbers.

    Thank you for your time and have a good day
    I am so skeptical, I can hardly believe it!
    PS I am not a 'hyperactive member' I am a cool, calm, and collected member

  2. #2

    Thread Starter
    Hyperactive Member badgers's Avatar
    Join Date
    Sep 1999
    Location
    Madison, WI USA
    Posts
    444
    here is the code I am trying to make work, but the loop never runs.

    Code:
    On Error Resume Next
    For i = 0 To Check1.UBound
        If Check1(i).Value = True Then
            If Err Then
                Err.Clear
                GoTo TryAgain
            End If
            ObjAcad.ActiveDocument.Open ("P:\details\plbg\" & Check1(i).Tag)
            ObjAcad.ActiveDocument.SendCommand ("(setq pntr " & Chr(34) & pntr & Chr(34) & ") ")
            ObjAcad.ActiveDocument.SendCommand ("filedia 0 ")
            ObjAcad.ActiveDocument.SendCommand _
                ("(load " & Chr(34) & "l:/homegrp/mep/cad/programs/prntdets.lsp" & Chr(34) & ") ")
            ObjAcad.ActiveDocument.SendCommand ("(c:prntdets) ")
            Check1(i).Value = False
        End If
    TryAgain:
    Next i
    the heart of the loop does stuff with autocad, (it works). I just never run the code in the loop.
    I am so skeptical, I can hardly believe it!
    PS I am not a 'hyperactive member' I am a cool, calm, and collected member

  3. #3
    Lively Member
    Join Date
    Aug 2000
    Location
    Ontario, Canada
    Posts
    79
    What about getting to the root of the problem and creating a little app to go through the form module and renumbering the controls manually?

    Code:
         'Check for "Begin VB.CheckBox cbArray"
         'Change the line Index           =   X to something else
    Quick and Dirty....

  4. #4
    Addicted Member
    Join Date
    Oct 2000
    Posts
    208
    How about . . .

    Dim ctl as Control
    For Each ctl in Me.Controls
    If Typeof ctl is CheckBox Then
    If ctl.Value = True then
    <Do your thing>
    End If
    End If
    Next ctl

  5. #5

    Thread Starter
    Hyperactive Member badgers's Avatar
    Join Date
    Sep 1999
    Location
    Madison, WI USA
    Posts
    444
    how can I tell what number in the array the check box is?
    If the check box is number 30 in the array I need to know so that I can reference number 30 in the label array.

    thank you for your time and have a good day
    I am so skeptical, I can hardly believe it!
    PS I am not a 'hyperactive member' I am a cool, calm, and collected member

  6. #6
    Addicted Member
    Join Date
    Oct 2000
    Posts
    208
    Dim ctl as Control
    Dim Index as Integer
    For Each ctl in Me.Controls
    If Typeof ctl is CheckBox Then
    If ctl.Value = True then
    Index = ctl.index
    Debug.Print Index <Or do whatever with the Index>
    <Do your thing>
    End If
    End If
    Next ctl

    If you have other checkboxes on the form that aren't part of the array, you might run into some problems. But those are easy enough to work around. Let me know if that's the case.

  7. #7

    Thread Starter
    Hyperactive Member badgers's Avatar
    Join Date
    Sep 1999
    Location
    Madison, WI USA
    Posts
    444
    thanks for your help.
    It works great now
    I am so skeptical, I can hardly believe it!
    PS I am not a 'hyperactive member' I am a cool, calm, and collected member

  8. #8
    Addicted Member
    Join Date
    Oct 2000
    Posts
    208
    Yay! It feels so great to help someone; I'm a really new VB programmer (~6 months), so I feel like I'm progressing!

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