Tipp 2.10 - Typ eines Controls
Wie kann ich die Typbezeichnung eines Controls ermitteln?
Mit dieser Funktion können Sie die Typbezeichnung eines Steuerelementes ermitteln. Kopieren Sie einfach nachfolgenden Quellcode in die Zwischenablage und fügen Sie anschließend den Inhalt der Zwischenablage in ein neues Modul ein. Die Aufrufparameter finden Sie im Quellcode beschrieben.
Beispiel:
Public Function A2XGetCtlType(pctl As Control) As String '// ===================================================== '// Methode | Ermittelt den Type eines Controls '// ----------------------------------------------------- '// Parameter | pctl - Control '// ----------------------------------------------------- '// Rückgabe | String - Controltyp '// ----------------------------------------------------- '// Erstellt | Manuela Kulpa '// | EDV Innovation & Consulting - Dormagen '// ----------------------------------------------------- '// Beispielaufruf: '// ?A2XGetCtlType(Me!txtData) '// ===================================================== Dim sType As String On Error GoTo A2XGetCtlType_Error Select Case pctl.ControlType Case acLabel sType = "Bezeichnungsfeld" Case acRectangle sType = "Rechteck" Case acLine sType = "Linie" Case acImage sType = "Bild" Case acCommandButton sType = "Befehlsschaltfläche" Case acOptionButton sType = "Optionsfeld" Case acCheckBox sType = "Kontrollkästchen" Case acOptionGroup sType = "Optionsgruppe" Case acBoundObjectFrame sType = "Gebundenes Objektfeld" Case acTextBox sType = "Textfeld" Case acListBox sType = "Listenfeld" Case acComboBox sType = "Kombinationsfeld" Case acSubform sType = "Unterformular / -bericht" Case acObjectFrame sType = "Objektfeld oder Diagramm" Case acPageBreak sType = "Seitenumbruch" Case 124 sType = "Seite" Case 123 sType = "Register" Case acCustomControl sType = "ActiveX-Control" Case acToggleButton sType = "Umschaltfläche" End Select A2XGetCtlType = sType A2XGetCtlType_Exit: On Error GoTo 0 Exit Function A2XGetCtlType_Error: Select Case Err.Number Case Else MsgBox "Fehler " & Err.Number & ": " & _ Err.Description, vbCritical, _ "modFrm.A2XGetCtlType" End Select Resume A2XGetCtlType_Exit End Function