Hi!!
Ich bins schon wieder mal.
Entweder steht ich auf der Leitung oder ich denk zu kompliziert. Ich hatte am 5.7. ein Problem beim Auslesen einer Listbox. Das Problem hat ist Dank Maywood gelöst, leider sind 2 weitere aufgetreten.
Den Code schreibe ich am Schluss.
1. Problem: Die markierten Zeilen schreibt er zwar tadellos ins Excel, aber leider doppelt.
2. Problem: Er liest nicht nur die markierten Zeilen aus sondern noch 2-3 Zeilen darunter auch, die nicht markiert wurden.
Wo liegt bzw. liegen bei meinem Programm der bzw. die Fehler??
lg Tina
If anzahl > 0 Then
For a = a To lv.Anz
lv.Rec = a
Dim text As String = Nothing
For Each k As String In Me.IstListe.SelectedItems
text = k
Dim split As String() = text.Split(New [Char]() {" "c})
For i = 0 To split.Length - 1
If Not split(i) = "" Then
If (Trim(lv.PNr) = Trim(split(i))) Then
CType(xlBlatt.Cells, Excel.Range)(curRow, 1) = _
lv.PNr
CType(xlBlatt.Cells, Excel.Range)(curRow, 2) = _
lv.KTx
CType(xlBlatt.Cells, Excel.Range)(curRow, 3) = _
lv.PoA
CType(xlBlatt.Cells, Excel.Range)(curRow, 4) = _
lv.HKZ
CType(xlBlatt.Cells, Excel.Range)(curRow, 5) = _
lv.LvM
CType(xlBlatt.Cells, Excel.Range)(curRow, 6) = _
lv.EH
If Not lv.EH = "" Then
CType(xlBlatt.Cells, Excel.Range)(curRow, _
7) = "0"
CType(xlBlatt.Cells, Excel.Range)(curRow, _
8) = "0"
CType(xlBlatt.Cells, Excel.Range)(curRow, _
9) = "0"
CType(xlBlatt.Cells, Excel.Range)(curRow, _
10) = "0"
End If
curRow += 1
ElseIf lv.PNr.StartsWith(split(i)) Then
CType(xlBlatt.Cells, Excel.Range)(curRow, 1) = _
lv.PNr
CType(xlBlatt.Cells, Excel.Range)(curRow, 2) = _
lv.KTx
CType(xlBlatt.Cells, Excel.Range)(curRow, 3) = _
lv.PoA
CType(xlBlatt.Cells, Excel.Range)(curRow, 4) = _
lv.HKZ
CType(xlBlatt.Cells, Excel.Range)(curRow, 5) = _
lv.LvM
CType(xlBlatt.Cells, Excel.Range)(curRow, 6) = _
lv.EH
If Not lv.EH = "" Then
CType(xlBlatt.Cells, Excel.Range)(curRow, _
7) = "0"
CType(xlBlatt.Cells, Excel.Range)(curRow, _
8) = "0"
CType(xlBlatt.Cells, Excel.Range)(curRow, _
9) = "0"
CType(xlBlatt.Cells, Excel.Range)(curRow, _
10) = "0"
End If
curRow += 1
End If
End If
Next i
'Fortschrittsbalken erhöhen
ProgressBarEXE.Value += 1
Next
Next
If a = lv.Anz Then
ProgressBarEXE.Value = ProgressBarEXE.Maximum
Else
'Fortschrittsbalken erhöhen
ProgressBarEXE.Value += 1
End If
End If |