count forms opened

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kowndinya
    New Member
    • Sep 2006
    • 26

    #1

    count forms opened

    I want to count all opened forms and list captions of all the forms. There is a loop control. I forgot it. can someone help me please.

    thanks
    raj
  • navigator
    New Member
    • Oct 2006
    • 10

    #2
    Originally posted by kowndinya
    I want to count all opened forms and list captions of all the forms. There is a loop control. I forgot it. can someone help me please.

    thanks
    raj

    Do this:

    Code:
    Public Sub FindForms()
    Dim frx As Form, fCount As Integer
      For Each frx In Forms()
        fCount = fCount + 1
        Debug.Print frx.Caption
      Next
      Debug.Print "Total forms found: " & Format(fCount)
    End Sub

    Hope it solves your problem... :-)

    Comment

    • kowndinya
      New Member
      • Sep 2006
      • 26

      #3
      Originally posted by navigator
      Do this:

      Code:
      Public Sub FindForms()
      Dim frx As Form, fCount As Integer
        For Each frx In Forms()
          fCount = fCount + 1
          Debug.Print frx.Caption
        Next
        Debug.Print "Total forms found: " & Format(fCount)
      End Sub

      Hope it solves your problem... :-)
      thanks. Now my problem is solved.
      raj

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by kowndinya
        thanks. Now my problem is solved.
        raj
        Thanks from me, too. I like to think that I know a reasonable amount about VB6. But I had always thought (incorrectly as it turns out) that the Forms() collection included all the forms in your project, not just the open ones. It's always nice to learn something new. :)

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Sorry, one more point raj. You can get the count directly form the Forms.Count property if you don't need the captions.

          Comment

          • kowndinya
            New Member
            • Sep 2006
            • 26

            #6
            Originally posted by Killer42
            Sorry, one more point raj. You can get the count directly form the Forms.Count property if you don't need the captions.
            Thank you very much for giving additional information.
            bye
            raj

            Comment

            Working...