loop help please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mrcw
    New Member
    • Nov 2008
    • 82

    loop help please

    I'm trying to shorten this list

    Page01.Visible = False
    Page02.Visible = False
    Page03.Visible = False
    Page04.Visible = False
    Page05.Visible = False
    ...
    Page50.Visible = False

    (there are 50 entries in the list)

    I have tried writing a for to loop but I am stuck. I have got this far

    Dim i As Integer

    For i = 1 To 50
    Page(i).Visible = False
    Next

    now I get an error message sayin "expression is not a method or array....."
    Can somebody show me what the loop should be please.

    mrcw
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    The error message is self explanatory. Why you need a loop for that. A simple sub-procedure will do all that for you.

    Comment

    • smartchap
      New Member
      • Dec 2007
      • 236

      #3
      May try this:

      Dim j as string
      for i=1 to 50
      j=Page & i
      j.Visible=False
      next

      Comment

      • mrcw
        New Member
        • Nov 2008
        • 82

        #4
        Still not working

        Thanks for your suggestion Smartchap but it doesn't work.
        mrcw

        Comment

        • rpicilli
          New Member
          • Aug 2008
          • 77

          #5
          Originally posted by mrcw
          I'm trying to shorten this list

          Page01.Visible = False
          Page02.Visible = False
          Page03.Visible = False
          Page04.Visible = False
          Page05.Visible = False
          ...
          Page50.Visible = False

          (there are 50 entries in the list)

          I have tried writing a for to loop but I am stuck. I have got this far

          Dim i As Integer

          For i = 1 To 50
          Page(i).Visible = False
          Next

          now I get an error message sayin "expression is not a method or array....."
          Can somebody show me what the loop should be please.

          mrcw

          If you really want to do in this way you need to make the names the same.

          For any language Page1 is different from Page01.

          Taking the example of Smarchap you can do some changes on it.

          Dim j as string
          Dim myCtrl as new Object

          for i=1 to 50
          j="Page" & i.tostring("00" )

          myCtrl.Name = j

          myCtrl.Visible= False

          next


          Try this and let us know if worked.


          Rpicilli

          Comment

          Working...