Hvis du nu har kaldt alle dine controller noget pænt....dvs tekstbokse starter med txt, combobokse med cbo, checkbokse med chk osv dim ctl as Control For each ctl in me.controls if ucase(left(ctl.name,3)) = "TXT" then ctl.backcolor = vbGrey 'Indsæt farven her end if Next ctl
dim ctl as Control For each ctl in me.controls Select case ucase(left(ctl.name,3)) Case "TXT" ctl.backcolor = vbGrey 'Indsæt farven her CASE "CBO 'blablabla end if Next ctl
dim ctl as Control For each ctl in me.controls Select case ucase(left(ctl.name,3)) Case "TXT" ctl.backcolor = vbGrey 'Indsæt farven her CASE "CBO 'blablabla end select Next ctl
På en lidt anden måde, uafhængig af navnestandard:
Dim ctl As Control
For Each ctl In Me.Controls Select Case TypeName(ctl) Case "TextBox" ctl.BackColor = vbYellow Case "ListBox" ctl.BackColor = vbGreen End Select Next ctl
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.