?难道是时间在作祟?把
For i = 1 To ListView1.ListItems.Count
    If ListView1.ListItems(i).Checked Then
        myAmount = myAmount + Val(ListView1.ListItems(i).Text)
    end if
Next
放到按钮的click中(如果他们不在的话)

解决方案 »

  1.   

    没问题呀!
    Option ExplicitPrivate Sub Command1_Click()
    Dim i As Integer
    Dim myAmount As IntegerFor i = 1 To ListView1.ListItems.Count
        If ListView1.ListItems(i).Checked Then
            myAmount = myAmount + Val(ListView1.ListItems(i).Text)
            Debug.Print i, myAmount
        End If
    Next
    End SubPrivate Sub Form_Load()
    With ListView1
        .View = lvwReport
        .LabelEdit = lvwAutomatic
        .Checkboxes = True
    End WithListView1.ListItems.Add 1, "dsclub", 100End Sub
    'ListView1的列首项index 1 的关键字为dsclub
      

  2.   

    我是把数据库中的内容写到库中的,现在我贴上全部代码,可真的是出现我讲的问题
    Private Sub CheckSelect()
        Dim myRs As ADODB.Recordset
        Dim SinID As Long
        Dim FpID As Long
        Dim SinAmount As Double
        Dim FpAmount As Double
        Dim FpPrice As Double
        Dim FpMoney As Double
        Dim myAmount As Double
        Dim SumAmount As Double
        Dim SumMoney As Double
        Dim S As String
        Dim M As String
        Dim j As Integer
        SumMoney = 0
        j = 0
        If ListView1.ListItems.Count <= 0 Then Exit Sub
        For i = 1 To ListView1.ListItems.Count
            If ListView1.ListItems(i).Checked Then
                j = j + 1
                FpPrice = Val(ListView1.ListItems(i).SubItems(3))
                FpAmount = Val(ListView1.ListItems(i).SubItems(4))
                FpMoney = Val(ListView1.ListItems(i).SubItems(5))
                SinAmount = Val(ListView1.ListItems(i).SubItems(6))
                SinID = Val(ListView1.ListItems(i).SubItems(7))
                FpID = Val(ListView1.ListItems(i).SubItems(8))
                myAmount = Val(ListView1.ListItems(i).Text)
                If myAmount = 0 Then
                    MsgBox "就在这里出现这个奇怪的错误", , "系统提示"
                    Exit Sub
                End If
                If myAmount + SinAmount > FpAmount Then
                    MsgBox "核对数量不能大于发票开票数量!", , "系统提示"
                    Exit Sub
                End If
                If myAmount <> 0 Then
                    If myAmount + SinAmount = FpAmount Then
                        If Len(S) = 0 Then
                            S = CStr(FpID)
                        Else
                            S = S & ":" & CStr(FpID)
                        End If
                    End If
                    If Len(M) = 0 Then
                        M = CStr(FpID) & ":" & CStr(myAmount)
                    Else
                        M = M & "|" & CStr(FpID) & ":" & CStr(myAmount)
                    End If
                    SumAmount = SumAmount + myAmount + SinAmount '总的核对数
                    SumMoney = SumMoney + Round(SumAmount * FpPrice, 2)
                End If
                If SumAmount > RAmount Then
                    MsgBox "总的核对数量不能大于入库数量", , "系统提示"
                    Exit Sub
                End If
            End If
        Next
            If j = 0 Then Exit Sub
            mySAVE = True
    End Sub
      

  3.   

    to  jennyvenus() 与时间无关,我在语句前加入api
    Sleep 2000
    同样还是这种情况
    但是只要是调试状态时,就一切正常
      

  4.   

    问题解决,谢谢顶的各位
    可能这是VB的BUG
    当输入当标没有离开listview的编辑框时出现这个问题。
    解决办法
    加一个语名
    listview1.setfouce
    即可