Im new here and i want to make this code more simple:

If tabC.TabCount = 1 Then
            NClose.Enabled = False
            CloseNote.Enabled = False
            CloseNoteContext.Enabled = False
            CloseNoteX.Enabled = False
        Else
            NClose.Enabled = True
            CloseNote.Enabled = True
            CloseNoteContext.Enabled = True
            CloseNoteX.Enabled = True
        End If

I try this
NClose.Enabled, CloseNote.Enabled, CloseNoteContext.Enabled = True
But won't work. I want to google it, but don't know what keyword to type.

What exactly do you want to do? Please exert some effort into putting more details to your questions so others may help you out. ^^ God bless

Hi,

You could try something like:

Private Sub EnableDisableMyControls (Optional ByVal bEnabled As Boolean =TRUE)
    NClose.Enabled = bEnabled
    CloseNote.Enabled = bEnabled
    CloseNoteContext.Enabled = bEnabled
    CloseNoteX.Enabled = bEnabled
End Sub

If tabC.TabCount =1 Then
    EnableDisableMyControls(TRUE)
Else
    EnableDisableMyControls(FALSE)
End if

G Waddell's suggestion is the quickest way to do what you are wanting.

You could also replace

If tabC.TabCount =1 Then
    EnableDisableMyControls(TRUE)
Else
    EnableDisableMyControls(FALSE)
End if

with

EnableDisableMyControls(tabC.Tabcount = 1)
Member Avatar for Unhnd_Exception

Those are some pretty great answers. Leave it the way you have it.

Dim Enabled as boolean = tabC.tabcount <> 1

NClose.Enabled = Enabled
CloseNote.Enabled = Enabled
CloseNoteContext.Enabled = Enabled
CloseNoteX.Enabled = Enabled

Except your version does the opposite of what he wanted. He wants Enabled if the value is equal to 1.

Wow, thanks! this exactly what i want. Solved.

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.