vb中运行vba代码_记录对VB6或VBA代码的更改

本文介绍了在VB6和VBA项目中跟踪代码更改的重要性,并提出了一种有效的注释方法。作者通过添加名为ChangeLog的模块来记录每次更新的详细信息,以及开发了用于轻松注释代码的VB6和Excel VBA加载项工具。
摘要由CSDN通过智能技术生成

vb中运行vba代码

When changes need to be made to code, the easiest thing to do is obviously to just add, change or delete lines and be done with it. The problem with that is that after making several modifications you may find that you need to undo something you did and it may be difficult to remember what changes were made. It can also be difficult to remember

当需要对代码进行更改时,最简单的事情显然就是添加,更改或删除行并使用它来完成。 这样做的问题是,在进行了几处修改之后,您可能会发现您需要撤消所做的某些操作,并且可能很难记住所做的更改。 也可能很难记住

why and/or when you made the changes.

I learned by experience that the easy method is not the best method and so I started annotating my changes like the following...

我从经验中学到,简单的方法不是最好的方法,因此我开始注释我的更改,如下所示...

where this is the original code

这是原始代码

    gbQuit = True
    frmProject.lblCounting.Caption = "Quit command accepted..."
    frmProject.tbarProject.Buttons(3).Enabled = False
    mnuPrint.Enabled = False

and this is the modified code.

这是修改后的代码。

    
    gbQuit = True
    'new
    frmProject.lblCounting.Caption = "Quit command accepted..."
    'frmProject.tbarProject.Buttons(3).Enabled = False
    frmProject.tbarProject.Buttons(4).Enabled = False

    mnuPrint.Enabled = False

That would indicate to me that I changed the line that refers to the 'Buttons' and showed me what is was before, and the blank line indicated that the change ended on the line above it. That's all well and good but it doesn't help resolve the why and when issue.

这将向我表明我已更改了引用“按钮”的行,并向我显示了之前的内容,而空行则表明更改已在其上方的行结束。 一切都很好,但这无助于解决问题的原因和时间。

My annotation scheme now includes two ingredients.

我的注释方案现在包括两个要素。

Part 1.

第1部分。

I add a module named ChangeLog to every project. The contents of ChangeLog always look something like the following. For certain projects there may be a Programmer Name column and/or other data, but the actual format isn't important as long as the why and when information is included.

我向每个项目添加一个名为ChangeLog的模块。 ChangeLog的内容始终类似于以下内容。 对于某些项目,可能会有“程序员名称”列和/或其他数据,但是实际格式并不重要,只要包括为什么和何时包含信息即可。

Option Explicit

显式期权

'*********************************************************************************

'***************************** ********** ********** ********** ********** ********** ******

'*                                                          CHANGE LOG                                                         *

'*更改日志*

'*********************************************************************************

'***************************** ********** ********** ********** ********** ********** ******

'Release   Date      Change Description

'发布日期更改说明

'-------   --------  -------------------------------------------------------------

'------- -------- ------------------------- ---------- ---------- ---------- ------

'01.00     07/07/08  (a) Initial release

'01 .00 07/07/08(a)初始版本

'01.10     07/15/08  (a) Several changes to zoom function including:

'01 .10 07/15/08(a)缩放功能的多项更改,包括:

'                        - Prevent zoomed image from becoming too large, or smaller than

'-防止缩放的图像过大或过小

'                          original size

' 原始尺寸

'                        - Ctrl_r = re-center

'-Ctrl_r =重新居中

'                        - Magnifying glass cursor

'-放大镜光标

'                    (b) Found a second camera manufacturers comment,

'(b)找到第二家相机制造商的评论,

'                        so created frmComment dialog, gcolExclude (comments to be excluded),

'这样就创建了frmComment对话框,gcolExclude(要排除的注释),

'                        and mnuComments

'和mnuComments

'                    (c) Corrected problems when app closed in "Full Screen" mode

'(c)更正了在“全屏”模式下关闭应用程序时的问题

'01.20     07/25/08  (a) Added crop function

'01 .20 07/25/08(a)添加了裁剪功能

'                    (b) Added tooltips to frmDisplay

'(b)在frmDisplay中添加了工具提示

'                    (c) Corrected a problem where the same starting tooltip was always shown

'(c)更正了始终显示相同的启动工具提示的问题

'                        depending on how they were handled

'取决于处理方式

Part 2.

第2部分。

I've developed add-ins for both VB6 and Excel VBA that allow for easy code annotation. The VBA version probably works for other Office applications in addition to Excel but I haven't tried it. Please leave a comment to let me know if you were successful or not.

我已经为VB6和Excel VBA开发了加载项,这些加载项可简化代码注释。 VBA版本可能适用于除Excel之外的其他Office应用程序,但我还没有尝试过。 请发表评论,让我知道您是否成功。

Once installed and turned on (see instructions below), this toolbar will appear. Excel users note: This toolbar will appear in the Visual Basic toolbar, not in the workbook ribbon or in the workbook Add-Ins drop-down.

一旦安装并打开(请参阅下面的说明),该工具栏就会出现。 Excel用户注意:此工具栏将显示在Visual Basic工具栏中,而不出现在工作簿功能区或工作簿加载项下拉列表中。

Annotate Add-in Toolbar

Annotate Selected Text

注释选定的文本

Set Descriptive Text

设置描述文字

Set Templates

设置模板

    '******* 01.20a Start *******
    ' Initialize zoom parameters
    mintZoomClicks = 0
    ReDim mDimensions(1 To 15) As ImageDimensions
    '******* 01.20a End *********

After writing the two lines of actual code and adding the comment (like every good programmer does), the steps that resulted in the annotation were:

在编写了两行实际代码并添加了注释之后(就像每个好的程序员一样),导致注释的步骤是:

1. This step just needs to be done just once as it is saved for all programming sessions. Click the 'Set Templates' button which will show you this window.

1.

Set Templates

2. Click the 'Set Descriptive Text' button which will show you this window

2.单击“设置描述性文字”按钮,将显示此窗口

Enter-descriptive-text.jpg

3. Finally, just highlight the lines that you added or changed and press the 'Annotate' button and you'll get something like my annotation shown above.

3.最后,只需突出显示您添加或更改的行,然后按“注释”按钮,您将得到上面显示的类似我的注释的内容。

When you close Excel or VB6 and you've changed the descriptive text you'll see a message like this:

当您关闭Excel或VB6并更改了描述性文字时,您会看到以下消息:

Descriptive Text changed

I haven't mentioned the other two buttons yet because they have nothing to do with annotation. You can consider them a bonus and they are:

我还没有提到其他两个按钮,因为它们与注释无关。 您可以将它们视为奖励,它们是:

Clear Immediate Window

清除即时窗口

Close other IDE Windows

关闭其他IDE Windows

Installing the Add-Ins

安装加载项

VB6 VB6

Download the AnnotateVB6.txt attachment and change the name to AnnotateVB6.dll. It doesn't matter where you store it. Once you have the file renamed you need to register the dll. To do that go to Start|Run and enter regsvr32 C:\AnnotateVB6.dll on the 'Open:' line and press OK. You should get a message saying that the registration was successful.

下载AnnotateVB6.txt附件,并将名称更改为AnnotateVB6。 dll文件 。 存放在哪里都无所谓。 将文件重命名后,您需要注册dll。 为此,请转到“开始” |“运行”,然后在“打开:”行上输入

AnnotateVB6.txt AnnotateVB6.txt

The final step is to go to the VB6 IDE and select the Add-Ins|Add-In Manager… menu item and select 'AnnotateVB6' from the list. Under 'Load Behavior I suggest selecting both available options.

最后一步是转到VB6 IDE,然后选择“

Excel 电子表格

Download the AnnotateVBA.txt attachment and change the name to AnnotateVBA.dll. It doesn't matter where you store it. Once you have the file renamed you need to register the dll. To do that go to Start|Run and enter regsvr32 C:\AnnotateVBA.dll on the 'Open:' line and press OK. You should get a message saying that the registration was successful.

下载AnnotateVBA.txt附件,并将名称更改为AnnotateVBA。 dll文件 。 存放在哪里都无所谓。 将文件重命名后,您需要注册dll。 为此,请转到“开始” |“运行”,然后在“打开:”行上输入

AnnotateVBA.txt AnnotateVBA.txt

The final step is to go to the Excel VBE and select the Add-Ins|Add-In Manager… menu item and select 'AnnotateVBA' from the list. Under 'Load Behavior I suggest selecting both available options.

最后一步是转到Excel VBE,然后选择“

Note that while this is a COM add-in you won't see it listed if you go to either File|Options|Add-Ins|COM Add-Ins (or Excel Add-ins).

请注意,尽管这是一个COM加载项,但是如果您转到File | Options | Add-Ins | COM加载项(或Excel加载项),则不会看到它的列出。

If you find that this article has been helpful, please click the “thumb’s up” button below. Doing so lets me know what is valuable for EE members and provides direction for future articles. It also provides me with positive feedback in the form of a few points. Thanks!

如果您发现本文对您有所帮助,请单击下面的“竖起大拇指”按钮。 这样做可以让我知道对EE成员有价值的内容,并为以后的文章提供指导。 它还以几点的形式为我提供了积极的反馈。 谢谢!

翻译自: https://www.experts-exchange.com/articles/11093/Documenting-changes-to-VB6-or-VBA-code.html

vb中运行vba代码

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值