我有一个简短的问题。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 的数量会扼杀这种速度优势?