Home > Software engineering >  Enabled especifics btns in a form
Enabled especifics btns in a form

Time:01-19

I want to have a command to enable determinant buttons in my form, all in one.

Today I need to inform with button this way:

public function EnabledMenu ()

Form_FrmMenu.btnAnalyze.Enabled = True
Form_FrmMenu.btnVacation.Enabled = True
Form_FrmMenu.btnTicket.Enabled = True
Form_FrmMenu.btnBackup104.Enabled = True

end function

what I want is like below, but ocorrs an error: Expected: identifier or bracketed expression

public function EnabledMenu()

Dim vBtns1 As Variant
    vBtns1 = Array(btnAnalyze, btnVacation, btnTicket, btnBackup104, btnParameterStr)

Dim vBtn1 As Variant

For Each vBtn1 In vBtns1
    Form_FrmMenu. & vbtn1 & .enebled = true
Next vbtn

end function

it's possible ?

CodePudding user response:

You typically do this with the names of the controls (string).

Dim arr As Variant
    arr = Array("btnAnalyze", "btnVacation", "btnTicket", "btnBackup104", "btnParameterStr")

Dim btn As Variant

For Each btn In arr 
    Form_FrmMenu.Controls(btn).Enabled = true
Next vbtn
  • Related