我为自己的酒吧创建了一个possapp。一切正常,但删除1个或多个项目时我必须重新计算列表框。 这是我的删除按钮代码
Private Sub CommandButton84_Click()
Dim ItemTarget&, s, i%
s = 0
ItemTarget = ListBox1.ListCount
If ItemTarget > 0 Then
Me.ListBox1.RemoveItem ItemTarget - 1
For i = 0 To Me.ListBox1.ListCount - 1
s = s + Val(Me.ListBox1.List(i, 1))
Next
Me.TextBox1 = s
Else
MsgBox "De lijst is reeds leeg", vbInformation, "Café De Zoete Inval"
End If
Me.TextBox4 = Me.ListBox1.ListCount
End Sub
答案 0 :(得分:0)
私人子CommandButton100_Click()
Dim LItem As Long
Dim IRange As Integer
Dim sht As Worksheet
Dim LastRow As Long
Dim rows As Integer
rows = 0
设置sht = ActiveSheet
For LItem = 0 To ListBox1.ListCount - 1
ListBox1.ColumnCount = 2
With Worksheets("Sheet6")
.Cells(LItem + 7, 1) = ListBox1.List(LItem, 0)
.Cells(LItem + 7, 2) = ListBox1.List(LItem, 1)
.Cells(LItem + 8, 1).EntireRow.Insert
rows = rows + 1
End With
With Sheets("Histo")
LastRow = .Cells.Find("*", searchorder:=xlByRows,
searchdirection:= xlPrevious)。行
If Time < "07:00:00" Then
.Cells(LastRow + 1, 1) = Format(Date - 1, "dd-mm-yyyy")
Else
.Cells(LastRow + 1, 1) = Date
End If
.Cells(LastRow + 1, 2) = ListBox1.List(LItem, 0)
.Cells(LastRow + 1, 3) = ListBox1.List(LItem, 1)
End With
下一个LItem
使用ThisWorkbook.Sheets(“ Sheet6”)
ListBox1.Clear
TextBox2.Value =“”
TextBox1.Value = 0
Range(“ Sheet6!B5”)。ClearContents
对于i = 1到行
.Cells(7,1).EntireRow.Delete
下一步
结尾为
ActiveWorkbook.Save
结束子
私人子CommandButton1_Click()
使用ThisWorkbook.Sheets(“ Sheet1”)
Me.ListBox1.AddItem .Range(“ B2”)。Value
Me.ListBox1.Column(1,ListBox1.ListCount-1)= Format(Val(.Range(“ C2”)。Value),
“€#,## 0.00”)
Me.TextBox1.Value = CDbl(Me.TextBox1.Value)+ .Range(“ C2”)。Value
Me.TextBox1.Value = Format(Me.TextBox1.Value,“#,## 0.00”)
结尾为
Me.TextBox4 = Me.ListBox1.ListCount
结束子