2

我正在.bas.xls此处概述的文件中导出文件:Exporting A VBComponent Code Module To A Text File以将它们签入到 SVN 存储库中。

我遇到了以下问题,它导致文件中变量名的大小写发生变化,这实际上不是真实的(或至少不相关)。

像这样的语句被重新格式化/重新格式化:

rngTenors.Cells(i, 1) 
changes into 
rngTenors.cells(i, 1)

(微妙但仍然不同,它被我使用的差异工具拾取,并将文件的真实变化隐藏在由此产生的噪音中)

任何防止这种情况发生的方法的想法将不胜感激。

4

3 回答 3

1

我正在做类似的事情,但还没有看到你正在经历什么。我没有使用相同的导出例程,但乍一看它们看起来很相似。

几个问题。

1)你在使用option explicit,你有一个cell 在任何地方命名的变量吗?

2)如果你提交,然后做一些更改,导出 .bas 文件并再次提交,差异是什么样的?

3)您是否在可能会改变您的大小写的代码感知编辑器(例如:Ultraedit)中打开和比较 .bas 文件?

我只是在猜测...但是如果您将变量命名为与方法或属性相同的名称,那么 VB 编辑器的大小写可能会很奇怪。我也不明白为什么你的出口会不一致地出口.Cell我猜如果它出口到.cell那么它应该总是出口到.cell而不是问题。

这些只是一些想法,祝你好运:)

于 2009-07-26T14:19:37.797 回答
1

The VBE keeps an internal cache of variable names, including the casing, so even though you found a variable called cell, and renamed it to be something else, VBA still thinks it is a valid name, and so it is preserving the casing across all usages of that text.

You can trick the VBE into resetting the variable casing (and this also works for casing problems on methods too) by temporarily declaring a variable with the correct casing:

Public Cell as String

And then deleting that variable. You should then find that all of the casings are fixed throughout your project (and any project that refers to it).

于 2016-12-22T22:43:11.567 回答
0

确实,我在代码中发现了上面建议的内容。

dim cell

I have now renamed this variable and no reformats have occurred since. I expect and hope that this has resolved the issue. Many thanks for help!

于 2009-07-27T11:13:04.790 回答