views:

67

answers:

1

I'm having an issue referencing public procedures of User Controls that I've created within a VB6 project.

A simple example (exe), I have a form with a button and a user control:

Option Explicit

Private Sub Command1_Click()
   UserControl1.updateMessage ("TIME NOW: " & DateTime.Time)
End Sub

The User Control code is as follows:

Option Explicit

Public Sub updateMessage(ByVal newMessage As String)
   Label1.Caption = newMessage
End Sub

This exe compiles and works fine, and when I'm typing updateMessage in the Form, it appears in the intellisense list with the appropriate requirements. The issue I have is when I'm wanting to "go to the definition" of updateMessage, instead of going to the appropriate section of the code within the User Control, the message always returns with:

"Cannot jump to 'updateMessage' because it is in the library 'Unknown1' which is not currently referenced."

where the numbered suffix of "Unkown1" changes from time to time.

It seems that if there were no reference to this procedure, then it would not appear in the intellisense and the project shouldn't compile. When running this with MZTools (though the error appears regardless of this plug-in being installed), I can go into the updateMessage procedure, and use it to find all procedures calling this function, so the link between the two should exist (although I'm not sure if MZTools just finds using a text-matching pattern).

If anyone out there could shed some light on this matter, it would be very much appreciated, and save this poor VB6 developer a lot of hassle!

I have SP6 installed (build 9782) of VB6 and am running XP SP3 on an HP dx2400.

A: 

Yes, this is extremely annoying and I'm convinced it's a bug in VB6. I say this because, if you locate the updateMessage method in the object browser and double-click on it, you are taken to the definition. So, the compiler actually does know where the definition is, it just refuses to take you there with Shift+F2.

raven
Ugh, I was hoping it was just my build / references or something. It's not the end of the world, but slows me down having to do a search for the name each time. I also have a suspicion this has something to do with the fact that it treats the UserControls as a compiled control, and doesn't try to access their source. Any thoughts?
alex.zambila
I'm not really up on the low-level mechanics of UserControls, I just know they are annoying at times. I find this particular issue so annoying that I often find myself browsing the code with a tool called Project Analyzer http://www.aivosto.com/project/project.html It is able to take me to UC member definitions simply by clicking on them. We purchased the Enterprise edition 5 or 6 years ago (version 7) and I've found it really helpful. The price has skyrocketed since then, but you may want to check it out if you know you are going to be doing a lot of work in VB6.
raven
And what's a shame? Microsoft is not going to do anything about it because they'd really like for you to stop using VB6! That said, though, it sort of makes sense: usercontrols are meant to be packaged as components, so you'd expect that an end-user would right-click on the method and go to the Object Browser. Of course, it makes no sense at all when you've got the code there....
David T. Macknet