With rs
.AddNew
.Fields("A") = Val(Text1.Text)
.Fields("B") = Val(Text2.Text)
.Fields("C") = val(Text3.Text)
.Fields("D") = val(Text4.Text)
If Val(Text1.Text) <> 0 Then
.Fields("A1") = Round(((Val(Text1.Text) - Val(Text2.Text)) / Val(Text1.Text)) * 100, 2)
Else
.Fields("A1") = 0
End If
If Val(Text3.Text) <> 0 Then
.Fields("A2") = Round(((Val(Text3.Text) - Val(Text4.Text)) / Val(Text3.Text)) * 100, 2)
Else
.Fields("A2") = 0
End If
.Fields("E") = Round((Val(Text5.Text) + Val(Text6.Text)) / 2, 2)
.UpdateBatch
end with
E是A1,A2的平均值,为什么执行完之后,在表里E字段的值为0呢?
.AddNew
.Fields("A") = Val(Text1.Text)
.Fields("B") = Val(Text2.Text)
.Fields("C") = val(Text3.Text)
.Fields("D") = val(Text4.Text)
If Val(Text1.Text) <> 0 Then
.Fields("A1") = Round(((Val(Text1.Text) - Val(Text2.Text)) / Val(Text1.Text)) * 100, 2)
Else
.Fields("A1") = 0
End If
If Val(Text3.Text) <> 0 Then
.Fields("A2") = Round(((Val(Text3.Text) - Val(Text4.Text)) / Val(Text3.Text)) * 100, 2)
Else
.Fields("A2") = 0
End If
.Fields("E") = Round((Val(Text5.Text) + Val(Text6.Text)) / 2, 2)
.UpdateBatch
end with
E是A1,A2的平均值,为什么执行完之后,在表里E字段的值为0呢?
debug.print (Val(Text5.Text)+Val(Text6.Text))/2