我有一个 Amount Subtract 应用程序,其中用户多个金额
当某个特定用户想要扣除他/她的金额时,他会给出他/她的名字然后金额
For Exapmle (Visual Basic 6.0特定应用程序)
**Name**-----------------------------------**Amount**
John--------------------------------------200
John---------------------------------------200
John---------------------------------------200
如果约翰想减少他的数额,他会给100卢比,那么应该来的结果是
**Name**-----------------------------------**Amount**
John--------------------------------------100
John---------------------------------------200
John---------------------------------------200
但我的节目显示
**Name**-----------------------------------**Amount**
John--------------------------------------100
John---------------------------------------100
John---------------------------------------100
这是我的程序代码
Private Sub Command1_Click()
Dim temp,liab,v,nc As Integer
Dim result As Variant
Dim con As New ADODB.Connection
Dim RST As New ADODB.Recordset
Dim sSQL As String
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& App.Path & "\Customer.mdb;Persist Security Info=False"
sSQL = "Select * From Table1 Where Name ='" & Text1.Text & "'"
RST.Open sSQL, con, adOpenDynamic, adLockOptimistic
liab = CInt(Text3.Text)
Do Until RST.EOF
temp = CInt(RST("Amount").Value)
v = temp - liab
If v < 0 Then
RST("Amount") = 0
RST.Update
RST.MoveNext
nc = CInt(RST("Amount").Value)
RST("Amount").Value = nc + v
RST.Update
Exit Sub
Else
RST("Amount") = v
RST.Update
End If
RST.MoveNext
Loop
RST.Close
End Sub