For/Next loop Button Control?

possible to control button properties with for/next loop?

Page 1 of 1

4 Replies - 4777 Views - Last Post: 14 April 2010 - 10:10 AM Rate Topic: -----

#1 aero_bro  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-January 10

For/Next loop Button Control?

Posted 14 April 2010 - 09:02 AM

Hello,

Is it possible to use a for/next loop to automatically make changes to button properties?

This is the code I'm trying to make work:

For i as integer = 1 to 10
button (i).height = 10
next i

Thanks, Ken
Is This A Good Question/Topic? 0
  • +

Replies To: For/Next loop Button Control?

#2 ZRonZ  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 206
  • Joined: 09-January 09

Re: For/Next loop Button Control?

Posted 14 April 2010 - 09:18 AM

You can set the button height:
For i as integer = 1 to 10
    button.height = i
next i


Was This Post Helpful? 0
  • +
  • -

#3 aero_bro  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-January 10

Re: For/Next loop Button Control?

Posted 14 April 2010 - 09:32 AM

Thanks, but I'll clarify. I have 10 buttons that I want to have their height changed to say 10 pixels in height, or 50 pixels in height. Rather than having to type:

button1.height = 50
button2.height = 50
....
button10.height = 50

I was hoping there was a way to use a loop to do it automatically with a loop statement, because I have 10 buttons with 10 text boxes in 7 if statements, that all need to change size depending on the if conditions.

Thanks
Was This Post Helpful? 0
  • +
  • -

#4 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1623
  • View blog
  • Posts: 5,200
  • Joined: 25-September 09

Re: For/Next loop Button Control?

Posted 14 April 2010 - 09:37 AM

Is this what you're wanting
        For Each btn As Control In Me.Controls
            If TypeOf btn Is Button Then
                CType(btn, Button).Height = 50
            End If
        Next

Was This Post Helpful? 0
  • +
  • -

#5 aero_bro  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-January 10

Re: For/Next loop Button Control?

Posted 14 April 2010 - 10:10 AM

Awesome! that worked. Thanks so much.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1