如果我有
Dim jmlBobot As Double = 0
Dim hasil As String = "0000300005300113000000000000000000000"
For i = 0 To ds.Tables(0).Rows.Count - 1
Dim bobot() As String = Split(hasil, "0")
For j = 0 To bobot.Length - 1
jmlBobot = jmlBobot + CDbl(Val(bobot(j)))
Next
ListView1.Items.Add(jmlBobot)
Next
如何将项目之间的总和添加到listview?因为总和不合适应该只有16.但在listview项目中添加169,338等
答案 0 :(得分:0)
你可以使用LINQ来求和,以获得所需的'16'值:
Dim hasil As String = "0000300005300113000000000000000000000"
Dim sum As Integer = (From s As String In hasil.Replace("0"c, "") Select CInt(s)).Sum
ListView1.Items.Add(sum.ToString)
......如果我理解这就是你要做的事情。