So....
da ich jetzt vor dem Problem stehe, mit dem ich mich seit knapp 11 Stunden rumschlage
frage ich euch
kann ich/ihr den code umschreiben
Also ich hab eine Listview mit 15 Spalten
und die 5 soll ausgerechnet werden
Hier mal mein kompletter code : siehe Anhang...
Spoiler anzeigen
In Form 2 sind eben sämtliche Textboxen... bis auf 1,2 und 3 Da soll eben das Ergebnis rein ist egal in welcher
Hoffe ihr könnt mir helfen...
Aber nicht den Code klauen
Danke
Opera
Danke Manschula![:D](https://www.vb-paradise.de/wcf/images/smilies/biggrin.png)
Edit by Manschula: Für Code-Ausschnitte den entsprechenden Tag verwenden! --> VB-Tag eingefügt
da ich jetzt vor dem Problem stehe, mit dem ich mich seit knapp 11 Stunden rumschlage
frage ich euch
kann ich/ihr den code umschreiben
Also ich hab eine Listview mit 15 Spalten
und die 5 soll ausgerechnet werden
Hier mal mein kompletter code : siehe Anhang...
VB.NET-Quellcode
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim Ergebnis As Double = 0
- For Each item As ListViewItem In ListView1.Items
- Ergebnis = Ergebnis + CDbl(item.SubItems(5).Text)
- Next
- TextBox1.Text = Ergebnis.ToString
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- SaveFileDialog1.ShowDialog()
- Dim Path As String = SaveFileDialog1.FileName
- Dim AllItems As String = ""
- Try
- For Each item As ListViewItem In ListView1.Items
- AllItems = AllItems & item.Text & "#" & item.SubItems(1).Text & "#" & item.SubItems(2).Text & "#" & item.SubItems(3).Text & "#" & item.SubItems(4).Text & "#" & item.SubItems(5).Text & "#" & item.SubItems(6).Text & "#" & item.SubItems(7).Text & "#" & item.SubItems(8).Text & "#" & item.SubItems(9).Text & "#" & item.SubItems(10).Text & "#" & item.SubItems(11).Text & "#" & item.SubItems(12).Text & "#" & item.SubItems(13).Text & "#" & item.SubItems(14).Text & "#" & item.SubItems(15).Text & vbNewLine '& "#" & item.SubItems(16).Text
- Next
- AllItems = AllItems.Trim
- Catch ex As Exception
- End Try
- Try
- If My.Computer.FileSystem.FileExists(Path) Then
- My.Computer.FileSystem.DeleteFile(Path)
- End If
- My.Computer.FileSystem.WriteAllText(Path, AllItems, False)
- Catch ex As Exception
- MsgBox("Error" & vbNewLine & ex.Message, MsgBoxStyle.Exclamation, "Error ")
- End Try
- End Sub
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- OpenFileDialog1.ShowDialog()
- Dim Path As String = OpenFileDialog1.FileName
- Dim AllItems As String
- Try
- AllItems = My.Computer.FileSystem.ReadAllText(Path)
- Dim ItemLines As New TextBox
- ItemLines.Text = AllItems
- For Each line As String In ItemLines.Lines
- Dim a1() As String = line.Split("#")
- Dim ItemName As String = a1(0)
- Dim SubItem1 As String = a1(1)
- Dim SubItem2 As String = a1(2)
- Dim SubItem3 As String = a1(3)
- Dim SubItem4 As String = a1(4)
- Dim SubItem5 As String = a1(5)
- Dim SubItem6 As String = a1(6)
- Dim SubItem7 As String = a1(7)
- Dim SubItem8 As String = a1(8)
- Dim SubItem9 As String = a1(9)
- Dim SubItem10 As String = a1(10)
- Dim SubItem11 As String = a1(11)
- Dim SubItem12 As String = a1(12)
- Dim SubItem13 As String = a1(13)
- Dim SubItem14 As String = a1(14)
- Dim SubItem15 As String = a1(15)
- 'Dim SubItem16 As String = a1(16)
- Dim Item As New ListViewItem(ItemName)
- Item.SubItems.Add(SubItem1)
- Item.SubItems.Add(SubItem2)
- ListView1.Items.AddRange(New ListViewItem() {Item})
- Next
- Catch ex As Exception
- MsgBox("Error" & vbNewLine & ex.Message, MsgBoxStyle.Exclamation, "Error ")
- End Try
- End Sub
- Private Sub NeuToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NeuToolStripMenuItem.Click
- Form2.Show()
- End Sub
In Form 2 sind eben sämtliche Textboxen... bis auf 1,2 und 3 Da soll eben das Ergebnis rein ist egal in welcher
Hoffe ihr könnt mir helfen...
Aber nicht den Code klauen
![^^](https://www.vb-paradise.de/wcf/images/smilies/grin.png)
Danke
Opera
Danke Manschula
![:D](https://www.vb-paradise.de/wcf/images/smilies/biggrin.png)
Edit by Manschula: Für Code-Ausschnitte den entsprechenden Tag verwenden! --> VB-Tag eingefügt
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „M.Opera“ ()