要WITH还是不要WITH? [英] To WITH or not to WITH?

查看:88
本文介绍了要WITH还是不要WITH?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道

之间是否有使用WITH语句的速度优势或劣势。


例如,我将:


WITH Forms!myFormName

..ctlA = x

..ctlB = y

..ctlC = z

结束


比任何更好/更差:


Forms!myFormName。 ctlA = x

表格!myFormName.ctlB = y

表格!myFormName.ctlC = z


谢谢,

lq

I''m wondering if there is any speed advantage or disadvantage between
making use of WITH statements or not.

For example, will:

WITH Forms!myFormName
..ctlA = x
..ctlB = y
..ctlC = z
END WITH

be any better/worse than:

Forms!myFormName.ctlA = x
Forms!myFormName.ctlB = y
Forms!myFormName.ctlC = z

Thanks,
lq

推荐答案

lauren quantrell写道:
lauren quantrell wrote:
我想知道是否有



例如,将:

WITH Forms!myFormName
.ctlA = x
.ctlB = y
.ctlC = z


比任何更好/更差:

表格!myFormName .ctlA = x
Forms!myFormName.ctlB = y
Forms!myFormName.ctlC = z
谢谢,
lq
I''m wondering if there is any speed advantage or disadvantage between
making use of WITH statements or not.

For example, will:

WITH Forms!myFormName
.ctlA = x
.ctlB = y
.ctlC = z
END WITH

be any better/worse than:

Forms!myFormName.ctlA = x
Forms!myFormName.ctlB = y
Forms!myFormName.ctlC = z

Thanks,
lq




我的理解是,如果它可以消除性能,可以帮助提升性能(!)

或点(。)。在你的情况下,它消除了一个爆炸(每行),所以它应该比你拥有的第二个例子更好,但也许只是略微因为只有一个爆炸等级是
除去。如果With参考是一个非常长的,有很多

bang / dot水平,那么差异会更大。


我经常使用只是为了提高可读性即使我不是b / b
消除任何刘海或圆点,所以我认为即使

表现没有改善,它仍然是值得的。

-

我没有查看此邮件附带的电子邮件帐户

。发送给... ...

在Hunter dot com的RBrandt




My understanding is that With helps performance if it is eliminating Bangs (!)
or Dots (.). In your case it is eliminating one bang (per line) so it should be
better than the second example you have, but perhaps only marginally since only
one bang level is removed. If the With reference was a great long one with many
bang/dot levels then the difference would be bigger.

I often use With just for increased readability of the code even if I am not
eliminating any bangs or dots so I think it is still worthwhile even if
performance is not improved.

--
I don''t check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com



" Rick Brandt" < RI ********* @ hotmail.com>写在

新闻:FR *************** @ newssvr25.news.prodigy.net:
"Rick Brandt" <ri*********@hotmail.com> wrote in
news:FR***************@newssvr25.news.prodigy.net:
lauren quantrell写道:
lauren quantrell wrote:
我想知道在使用WITH语句之间是否有任何速度优势或劣势。

例如,将:

WITH Forms!myFormName
.ctlA = x
.ctlB = y
.ctlC = z
结束

表示!myFormName.ctlA = x
表格!myFormName.ctlB = y
表格!myFormName.ctlC = z
I''m wondering if there is any speed advantage or disadvantage
between making use of WITH statements or not.

For example, will:

WITH Forms!myFormName
.ctlA = x
.ctlB = y
.ctlC = z
END WITH

be any better/worse than:

Forms!myFormName.ctlA = x
Forms!myFormName.ctlB = y
Forms!myFormName.ctlC = z


表格! />
我的理解是,如果消除Bangs(!)或Dots(。),可以帮助提高性能。在你的情况下,它消除了一声(每行),所以它应该比你拥有的第二个例子更好,但也许只是稍微一点,因为只有一个爆炸等级被删除。如果With参考是一个很长的有很多
爆炸/点水平,那么差异会更大。

我经常使用只是为了增加代码的可读性甚至
如果我没有消除任何刘海或点,所以我认为即使性能没有提高,它仍然是值得的。



My understanding is that With helps performance if it is
eliminating Bangs (!) or Dots (.). In your case it is eliminating
one bang (per line) so it should be better than the second example
you have, but perhaps only marginally since only one bang level is
removed. If the With reference was a great long one with many
bang/dot levels then the difference would be bigger.

I often use With just for increased readability of the code even
if I am not eliminating any bangs or dots so I think it is still
worthwhile even if performance is not improved.




我不知道的!与。区别(我从不使用。

控制并认为它的编码风格很差),但我知道如果你

每次都完全参考表格,你在每个行的表单集合中强制查找

。以下几行

的代码需要长时间查看表单引用,并在每一行中引用

相同的表单:


Forms!Form1!ctlA = x

Forms!Form2!ctlB = y

Forms!Form3!ctlC = z


也就是说,上面不慢于:


表格!Form1!ctlA = x

表格!Form1!ctlB = y

表格!Form1!ctlC = z


每行必须查看表格是什么。


一种方法避免这是设置一个表单变量,所以你查找它

一次:


Dim frm As Form


设置frm = Forms!Form1

frm!ctlA = x

frm!ctlB = y

frm!ctlC = z

设置frm = Nothing


我不这样做,因为这意味着必须清理参考

完成后。 WITH因此更加清晰:


使用表格!表格1

!ctlA = x

!ctlB = y

!ctlC = z

结束


通过适当的缩进,它还有助于使代码更易于阅读,

在我看来。


-

David W. Fenton http://www.bway.net/~dfenton

dfenton at bway dot net http://www.bway.net/~dfassoc


WITH可能有一个小的速度优势。通常,当我们有更少的点和更少的对象变量时,速度会更快。$ / b

我知道为表单控件赋值​​的最快方法(并且一般来说

这种模式适用于所有对象的一切)是创建一个

对象指向!!!!具体!!!!一种控制,初始化

它,并按如下方式赋值:

Dim c As TextBox

设置c = Form_Form1.Controls(0)

c =" Jennie"

当然,如果只设置一次值,那么速度
这种方法的
优势可能因必须创建对象而被抵消

参考;然后它可能不会,因为设置对象引用是非常快的

。但除非我们将这些价值设定为数千美元,否则我们不太可能注意到所有的时差。



一般来说,如果一个人正在进行密集编码,数据操作,无论如何,可能值得声明每个对象的使用,并且

初始化对象尽快地。在复杂的计算中,

这样的策略可能会带来非常大的速度优势,例如花费10分钟的
,可能需要5秒后才能应用。

There might be a minor speed advantage to "WITH". Usually speed is
faster when we have fewer dots, and fewer object variables to look up.

The fastest way I know to assign value to form controls (and in general
this pattern works for everything for all objects) is to create an
object pointer to the !!!!specific!!!! kind of control, to initialize
it, and to assign its value as follows:

Dim c As TextBox
Set c = Form_Form1.Controls(0)
c = "Jennie"

Of course, if one is setting the value only once then the speed
advantage of this method may be offset by having to create the object
reference; then again it may not, as setting an object reference is
extremely fast. But unless we are setting these values thousands of
times it''s very unlikely that we will notice any time difference at
all.

In general, if one is doing intensive coding, data manipulation,
whatever, it may be worthwhile to declare EVERY object used, and to
initialize the object as soon as possible. In complex calculations,
such a strategy may result in very great speed advantages, eg something
that took 10 minutes, may take 5 seconds after this is applied.


这篇关于要WITH还是不要WITH?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆