【发布时间】:2015-02-05 23:16:37
【问题描述】:
我有一个简短的问题。 VBA之间有什么区别
if x1 and x2 and x3 and ... and x10 then
foo
end if
和
if x1 then
if x2 then
if x3 then
...
foo
end if
end if
end if
关于速度?
更具体地说: 我有 10 列数据,需要逐行比较数据库中的重复数据(在这种情况下,SELECT DISTINCT 之类的东西不起作用)。
我可以想象,使用
x1 = recordset.fields("Field1").value
if x1 then
x2 = recordset.fields("Field2").value
if x2 then
x3 = recordset.fields("Field3").value
if x3 then
...
foo
end if
end if
end if
会比
更快x1 = recordset.fields("Field1").value
x2 = recordset.fields("Field2").value
...
if x1 and x2 and x3 and ... and x10 then
foo
end if
因为我不必从记录集中读取所有数据。还是 ifs 的数量会扼杀这种速度优势?
【问题讨论】:
标签: vba ms-access if-statement flow-control