Results 1 to 3 of 3

Thread: Object arrays?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2002
    Location
    Cecilton, MD USA
    Posts
    278

    Object arrays?

    Is it possible to make an array of and object (like in VB6) such as

    Button(1).text="Hello"
    Button(2).text="hello2"

    you could do it in vb6 by simply copying and pasting an object and it would allow you to decide if you wanted it an array or not.

  2. #2
    Registered User
    Join Date
    Mar 2002
    Location
    Nashville, TN
    Posts
    103
    No, .NET doesn't allow for control arrays. What you can do, however, is create a standard event that handles the click event for a number of buttons. For example:

    Private Sub ButtonClick_Click(ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click

    Dim oButton as Button

    oButton = sender

    Select Case oButton.Name
    Case "Button1"
    Case "Button2"
    Case "Button3"
    End Select

    End Sub

    This seems to work pretty well. Hope it helps!

  3. #3
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    the way you use controls array is though collections
    \m/\m/

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