Benutzer mit den meisten Antworten
Control(s) auf einem Form an Function übergeben (Excel 2010 - vba)

Frage
-
Hallo @ all,
ich möchte gern diverse Einstellungen von Controls auf einem Form, per Function durchführen lassen.
Wie kann ich das machen.Also angenommen, ich möchte die Breite, Höhe, Position von oben, Position von links und Sichtbarkeit eines Controlls einstellen.
Hierzu wollte ich eine Function mit den Parametern erstellen. Klappt aber nicht - könnt Ihr mir helfen?Sub test() myControlSet frmStart, frmStart.Frame_Neu, True, 20, 50, 100, 100 End Sub <br/>Function myControlSet( _ ByRef Control_Name As MSForms.UserForm, _ ByRef myControl As Control, _ ByRef Control_Visible As Boolean, _ ByRef Control_TopPostion As Long, _ ByRef Control_LeftPostion As Long, _ ByRef Control_Width As Long, _ ByRef Control_Hight As Long) With Control_Name Stop End With End Function
Hier handelt es sich um ein Beispiel mit einem Frame, es sollte auch für andere Controlls verwendet werden (listbox, Image..)
Woher soll ich wissen, was ich denke, bevor ich höre, was ich sage?
Antworten
-
ich habe auf folgende Weise geschafft:
Sub test() myControlSet UserForm1.Frame1, True, 0, 0, 100, 100 End Sub Function myControlSet(ByRef myControl As Control, _ ByRef Control_Visible As Boolean, _ ByRef Control_TopPostion As Long, _ ByRef Control_LeftPostion As Long, _ ByRef Control_Width As Long, _ ByRef Control_Height As Long) myControl.Parent.Show 0 With myControl .Visible = Control_Visible .Top = Control_TopPostion .Left = Control_LeftPostion .Width = Control_Width .Height = Control_Height End With End Function
Der UserForm Parameter war nicht mehr notwendig. Was ich aber zusätzlich gemacht habe, ich habe das Formular erst angezeigt und dann alle Eigenschaften gesetzt.Viele Grüße,Bogdan
Ich bin gerne bei den Foren. Es kommt von Herzen. Es wird aber keine implizite oder sonstige Garantie für die geposteten Antworte / Informationen gewährt. Hier auch die Forenregeln.- Als Antwort markiert Bogdan Petru Roiu Freitag, 23. Dezember 2011 13:45
Alle Antworten
-
ich habe auf folgende Weise geschafft:
Sub test() myControlSet UserForm1.Frame1, True, 0, 0, 100, 100 End Sub Function myControlSet(ByRef myControl As Control, _ ByRef Control_Visible As Boolean, _ ByRef Control_TopPostion As Long, _ ByRef Control_LeftPostion As Long, _ ByRef Control_Width As Long, _ ByRef Control_Height As Long) myControl.Parent.Show 0 With myControl .Visible = Control_Visible .Top = Control_TopPostion .Left = Control_LeftPostion .Width = Control_Width .Height = Control_Height End With End Function
Der UserForm Parameter war nicht mehr notwendig. Was ich aber zusätzlich gemacht habe, ich habe das Formular erst angezeigt und dann alle Eigenschaften gesetzt.Viele Grüße,Bogdan
Ich bin gerne bei den Foren. Es kommt von Herzen. Es wird aber keine implizite oder sonstige Garantie für die geposteten Antworte / Informationen gewährt. Hier auch die Forenregeln.- Als Antwort markiert Bogdan Petru Roiu Freitag, 23. Dezember 2011 13:45