Mein Kampf mit der Klassenprogrannierung....
02.09.2013 19:39:20
robert
Hi,
mit strName wird eine Userform geladen,eine Listbox
und ein CommandButton erstellt.
Was ich nicht schaffe:
wenn in der Listbox eine Zeile markiert ist,
diesen Wert in Tabbelle3 einzutragen.
Das eintragen in die Tabelle schaffe ich schon, aber nicht,
dass der CommandButton in jeder Userform aktiv ist- Klasse ???
Danke für eine Hilfestellung
Gruß
robert
Option Explicit
' Klasse soll Ereignisse eines Objekts vom Typ CommandButton bereitstellen
Public WithEvents clButton As MSForms.commandbutton
Private Sub clbutton_Click()
Dim objUserform As Object
Dim objListBox As MSForms.ListBox
Dim objcb As MSForms.commandbutton
Dim strName As String
Dim scode As String
UserForm1.Hide
strName = clButton.Caption
Set objUserform = UserForms.Add(strName)
Set objListBox = objUserform.Controls.Add("Forms.ListBox.1")
On Error GoTo err
With objListBox
.Left = 10
.Top = 20
.Width = 250
.Height = 200
.ColumnCount = 2
.ColumnWidths = "200;30"
.RowSource = Range(strName).Address(External:=True)
.FontSize = 12
End With
Set objcb = objUserform.Controls.Add("Forms.CommandButton.1")
With objcb
.Left = 270
.Top = 20
.Width = 25
.Height = 200
End With
objUserform.Show
Set objListBox = Nothing
Set objUserform = Nothing
UserForm1.Show
err:
End Sub