Antwoorden
1. De propertiescollectie is de verzameling van alle eigenschappen. De eerste eigenschap heeft index 0 de laatste aantal-1
Function Lijst_eigenschappen()
Dim teller As Integer
For teller = 0 To Forms(0).Properties.Count - 1
Debug.Print Forms(0).Properties(teller).Name
Next teller
End Function
2. Hier wordt gebruik gemaakt van een objectvariabele f om het geopend formulier in te bewaren. De waarde bekomt men door properties(indexnummer) te plaatsen.
Function Lijst_eigenschappen()
Dim teller As Integer, f As Form
Set f = Forms(0)
For teller = 0 To f.Properties.Count - 1
Debug.Print f.Properties(teller).Name, f.Properties(teller)
Next teller
End Function
3. We gebruiken een objectvariabele c voor het bewaren van de verschillende controls of besturingselementen.
Function Lijst_controls()
Dim teller As Integer, f As Form, c As Control
Set f = Forms(0)
For teller = 0 To f.Controls.Count - 1
Set c = f.Controls(teller)
Debug.Print c.Name
Next teller
End Function
4. Alleen de tektvakken bekom je door de instructie:
If typeof control is controltype then
endif waarbij controltype textbox, label,... kan zijn
Function Lijst_controls()
Dim teller As Integer, f As Form, c As Control
Set f = Forms(0)
For teller = 0 To f.Controls.Count - 1
Set c = f.Controls(teller)
If TypeOf c Is TextBox Then
Debug.Print c.Name
End If
Next teller
End Function
5.
Function Lijst_controls()
Dim teller As Integer, f As Form, c As Control
Set f = Forms(0)
For teller = 0 To f.Controls.Count - 1
Set c = f.Controls(teller)
If TypeOf c Is TextBox Then
Debug.Print c.Name, c
End If
Next teller
End Function