JimDel
JimDel

Reputation: 4359

Is there a way to tell what the file name is where VB6 has only assigned it a number?

I'm working with some old VB6 code and it's still new to me. I know that in VB6 you assign an integer to represent a file. I have a program that uses quite a few files and it's tough to tell what file it's working with when it will only display the number when I mouse over the variable. (pic below).

enter image description here

So in the example above, how do i know what file #5 is?

Thanks

Upvotes: 6

Views: 326

Answers (2)

MarkJ
MarkJ

Reputation: 30398

  • 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.

Upvotes: 3

quamrana
quamrana

Reputation: 39354

You might have to modify the program to 'register' filenames with their file numbers:

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

Upvotes: 3

Related Questions