Results 1 to 7 of 7

Thread: [RESOLVED] Getting All the windows in an array

  1. #1

    Thread Starter
    Lively Member astroanu2004's Avatar
    Join Date
    Jan 2008
    Location
    Sri Lanka
    Posts
    108

    Resolved [RESOLVED] Getting All the windows in an array

    I have a MDI window and i want all of my child windows in a collection or and array. all my child windows are created with one form frmDoc and loaded using

    Code:
    Dim newD As New FrmDoc
    newD.Show
    so if i have all the forms in a collection i can change a property in the specific form's, object.

    Code:
    eg: 
    collection.items(1).cmd1.caption="ok"
    collection.items(5).cmd1.caption="ok"
    does anybody know how to do this?

  2. #2
    Addicted Member VB<3er's Avatar
    Join Date
    Jun 2008
    Location
    VBForums
    Posts
    133

    Re: Getting All the windows in an array

    Since i needed a good multiple document handling for my MDI based app i had some idea about this... u could create an array of frmDocs but they way u have it... try to do this:
    Code:
    Dim frm As Form
    For Each frm In Forms
    frm.cmd1.caption = "ok"
    Next
    Hope this helps if not tell me and i will tell u the array way
    REMEMBER if i've been useful RATE me plz

  3. #3

    Thread Starter
    Lively Member astroanu2004's Avatar
    Join Date
    Jan 2008
    Location
    Sri Lanka
    Posts
    108

    Re: Getting All the windows in an array

    ok how do i do this in an array? i want to do this as an array coz i need to call commands directly without for next loops using there indexed or ids.

  4. #4
    Addicted Member VB<3er's Avatar
    Join Date
    Jun 2008
    Location
    VBForums
    Posts
    133

    Re: Getting All the windows in an array

    Ah ok but if u want to call them all is faster with a loop
    Well this is the way i do it kk there maybe different ways but this works cool.
    Declarations:
    Code:
    Public newD() As New FrmDoc
    Public freei As Integer
    New document code:
    Code:
    freei = FreeIndex()
    If freei = 0 Then
        freei = 1
        ReDim newD(1 To 1)
      End If
    newD(freei).Show
    Free Index function:
    Code:
    Function FreeIndex() As Integer
    On Error GoTo errsub
    Dim i As Integer
    Dim ArrayC As Integer
        ArrayC = UBound(newD)
    ReDim Preserve newD(1 To ArrayC + 1)
    FreeIndex = UBound(newD)
    Exit Function
    errsub:
    FreeIndex = 0
    End Function
    Hope it helps!
    REMEMBER if i've been useful RATE me plz

  5. #5

    Thread Starter
    Lively Member astroanu2004's Avatar
    Join Date
    Jan 2008
    Location
    Sri Lanka
    Posts
    108

    Re: Getting All the windows in an array

    looks cool should work with my existing code. ill tell you if it worked. may be im gonna have to play around a little with this.
    thanx alot

  6. #6

    Thread Starter
    Lively Member astroanu2004's Avatar
    Join Date
    Jan 2008
    Location
    Sri Lanka
    Posts
    108

    Re: Getting All the windows in an array

    it works nicely. thanx a lot

  7. #7
    Addicted Member VB<3er's Avatar
    Join Date
    Jun 2008
    Location
    VBForums
    Posts
    133

    Re: [RESOLVED] Getting All the windows in an array

    No problem man ^^ glad to hear that!
    REMEMBER if i've been useful RATE me plz

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