Ok, here's the deal.

I'm trying to call make visible an object, i can do this:

Button1.Visible = True

but, i was wondering if there is a way that i can call it like this. Lets say i have a variable 'OBJNAME' wich value is "Button1". What i want to do is to make visible the button like this:

OBJNAME.Visible = True

I want to do this because i have like 100 objects to show in the form and i dont want to code for every one of them.

Is this possible? :)

You can easily loop all your form's controls

' Put this code in the form (Me refers to (your) form now)

Dim thisButtonName As String = "Button1" ' This is the name of the button you're looking for
Dim isButtonVisible As Boolean = True ' This is the "visibility" value you want to give/change

' Loop all controls in this form
For Each thisControl As Control In Me.Controls
    ' Is this control a button
    If TypeOf (thisControl) Is Button Then
        ' Is this the correct button
        If CType(thisControl, Button).Name = thisButtonName Then
            ' Set property's value
            CType(thisControl, Button).Visible = isButtonVisible
        End If
    End If
Next

This code checks for a specific button (inner if), but if you want to set visibility for all the buttons, drop the button's name testing.

HTH

If you are only interested in specific buttons on a page, a convenient way to distinguish them from other buttons is via the button.Tag property. Then inside the "is this a button" test you can check if button.Tag = "some value".

Thanksfor the answers! The first one solved my needs.

Thank you very much to both of you for taking a minute (or more) to help :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.