hallo,
ich hab ein problem und zwar funktioniert mir in folgendem beispiel "Box.RemoveItem e" nicht, ich erhalte dann die fehlermeldung "Laufzeitfehler '-2147024809 (80070057)': ungültiges Argument -2." . Was mache ich falsch?
Hier der Code:
Private Sub FillBoxes(Box As ComboBox, Nr As Integer)
Dim NeueMaterialienListe() As String
Dim AlteMaterialienListe() As String
Dim NeueMaterialien() As String
Dim i, b, laengeNML As Integer
Dim e As Variant
ReDim AlteMaterialienListe(Box.ListCount) As String
i = 4
help = 0
While Worksheets("Tabelle2").Cells(i, 2).Value <> ""
If Worksheets("Tabelle2").Cells(i, 3).Value = "" And Worksheets("Tabelle2").Cells(i, 2).Value <> "nichts" And Nr = 1 Then
If MsgBox("Achtung, keine Wärmekennzahl! Wollen Sie weiterfahren?", vbOKCancel + vbInformation + vbDefaultButton2, "Hinweis") = vbCancel Then
End
End If
End If
laengeNML = 1 + laengeNML
i = i + 1
Wend
ReDim NeueMaterialienListe(laengeNML - 1) As String
For N = 4 To i - 1
NeueMaterialienListe(N - 4) = Worksheets("Tabelle2").Cells(N, 2).Value
Next
ReDim NeueMaterialien(Box.ListCount + laengeNML - 1)
b = 0
For Each Material In Box.List
AlteMaterialienListe(b) = Material
b = b + 1
Next
e = 0
d = 0
For Each Materialalt In AlteMaterialienListe
c = 0
For Each Materialneu In NeueMaterialienListe
c = c + 1
If Materialalt = Materialneu Then
e = e + 1
Exit For
ElseIf c = laengeNML Then
NeueMaterialien(d) = Materialneu
Box.RemoveItem e -> Hier reklamiert er
d = d + 1
End If
Next
Next
For N = 0 To d - 1
Box.AddItem NeueMaterialien(N)
Next
Box.ListIndex = "0"
Call Cleartest
End Sub |