6

我正在使用一些旧的 VB6 代码,它对我来说仍然是新的。我知道在 VB6 中你分配一个整数来表示一个文件。我有一个使用很多文件的程序,当我将鼠标悬停在变量上时它只会显示数字时,很难判断它正在使用哪个文件。(下图)。

在此处输入图像描述

所以在上面的例子中,我怎么知道#5 是什么文件?

谢谢

4

2 回答 2

3
  • Search the code for the variable name? Do you have MZTools? It's a free plugin with excellent search facilities.
  • Trace the code execution back to see where the unit number comes from? Use the call stack view when debugging, or use MZTools to list all calls to any routine.
  • (Last resort) add logging.
    • Every time a file is opened, log the filename and unit number.
    • Every time a file is closed, log the unit number.
    • You could leave the logging in the production code, maybe with a way to turn it on/off at runtime. It could be useful again.
于 2013-06-01T07:46:50.323 回答
3

您可能必须修改程序以使用文件编号“注册”文件名:

Dim FileRegister as Collection

Dim FileName as String
Dim FileNumber as Integer

...

FileRegister.add FileName, str(FileNumber)
Open FileName For Output as #FileNumber

...

FileRegister.Remove str(FileNumber)
Close #FileNumber
于 2013-05-31T21:46:03.227 回答