Array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Roy Riddex

    Array

    Hi
    I have an array of command buttons which I set to 'enabled' in my program.
    This is done individually on seperate lines of code e.g.

    cmdButton(0).En abled = True
    cmdButton(1).En abled = True
    cmdButton(2).En abled = True
    cmdButton(3).En abled = True
    etc..

    Is there a way to group this coding onto one line e.g.

    cmdButton(0 to 10).Enabled = True

    I'm sure this has a simple solution but I can't find answers as yet, any
    help is much appreciated.


  • Rick Rothstein

    #2
    Re: Array

    > I have an array of command buttons which I set to 'enabled' in my
    program.[color=blue]
    > This is done individually on seperate lines of code e.g.
    >
    > cmdButton(0).En abled = True
    > cmdButton(1).En abled = True
    > cmdButton(2).En abled = True
    > cmdButton(3).En abled = True
    > etc..
    >
    > Is there a way to group this coding onto one line e.g.
    >
    > cmdButton(0 to 10).Enabled = True
    >
    > I'm sure this has a simple solution but I can't find answers as yet,[/color]
    any[color=blue]
    > help is much appreciated.[/color]

    One line? No. But we can reduce it to three for you...

    Dim btn As CommandButton
    For Each btn In Command1
    btn.Enabled = True
    Next

    Rick - MVP

    Comment

    • M. Posseth

      #3
      Re: Array

      well Rick ,,,


      we can also give him a one line solution ;-)

      Dim btn As CommandButton: For Each btn In Command1: btn.Enabled = True: Next

      M.Posseth - MCP




      "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
      news:e5KdnSv8__ 06MZ_cRVn-gw@comcast.com. ..[color=blue][color=green]
      > > I have an array of command buttons which I set to 'enabled' in my[/color]
      > program.[color=green]
      > > This is done individually on seperate lines of code e.g.
      > >
      > > cmdButton(0).En abled = True
      > > cmdButton(1).En abled = True
      > > cmdButton(2).En abled = True
      > > cmdButton(3).En abled = True
      > > etc..
      > >
      > > Is there a way to group this coding onto one line e.g.
      > >
      > > cmdButton(0 to 10).Enabled = True
      > >
      > > I'm sure this has a simple solution but I can't find answers as yet,[/color]
      > any[color=green]
      > > help is much appreciated.[/color]
      >
      > One line? No. But we can reduce it to three for you...
      >
      > Dim btn As CommandButton
      > For Each btn In Command1
      > btn.Enabled = True
      > Next
      >
      > Rick - MVP
      >[/color]


      Comment

      • Hari

        #4
        Re: Array

        If you are in VB.NET, i would handle it like this:

        Imports Microsoft.Visua l basic
        .....
        .....
        For counter = 0 To Ubound(cmdButto n)
        cmdButton(count er).Enabled. = True
        Next counter
        .....
        .....


        Comment

        Working...