Beispiele für ListBox-Steuerelement, Column-, ColumnCount-, List-Eigenschaften

The following example loads a two-dimensional array with data and, in turn, loads two ListBox controls using the Column and List properties. Beachten Sie, dass die Column-Eigenschaft die Arrayelemente beim Laden vertauscht.

Kopieren Sie den Beispielcode in den Deklarationsabschnitt eines Formulars, wenn Sie dieses Beispiel verwenden möchten. Stellen Sie sicher, dass das Formular zwei ListBox -Steuerelemente enthält: ListBox1 und ListBox2.

Dim MyArray(6,3) 
 
Private Sub UserForm_Initialize() 
 Dim i As Single 
 'The 1st list box contains 3 data columns 
 ListBox1.ColumnCount = 3 
 'The 2nd box contains 6 data columns 
 ListBox2.ColumnCount = 6 
 
 'Load integer values into first column of MyArray 
 For i = 0 To 5 
 MyArray(i, 0) = i 
 Next i 
 
 'Load columns 2 and three of MyArray 
 MyArray(0, 1) = "Zero" 
 MyArray(1, 1) = "One" 
 MyArray(2, 1) = "Two" 
 MyArray(3, 1) = "Three" 
 MyArray(4, 1) = "Four" 
 MyArray(5, 1) = "Five" 
 
 MyArray(0, 2) = "Zero" 
 MyArray(1, 2) = "Un ou Une" 
 MyArray(2, 2) = "Deux" 
 MyArray(3, 2) = "Trois" 
 MyArray(4, 2) = "Quatre" 
 MyArray(5, 2) = "Cinq" 
 
 'Load data into ListBox1 and ListBox2 
 ListBox1.List() = MyArray 
 ListBox2.Column() = MyArray 
 
End Sub

Support und Feedback

Haben Sie Fragen oder Feedback zu Office VBA oder zu dieser Dokumentation? Unter Office VBA-Support und Feedback finden Sie Hilfestellung zu den Möglichkeiten, wie Sie Support erhalten und Feedback abgeben können.