Results 1 to 18 of 18

Thread: [RESOLVED] Project-Name Table entries

  1. #1

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Resolved [RESOLVED] Project-Name Table entries

    I asked this question about three years ago, but never got an answer.

    Has anyone ever figured out how to get a list of the entries in VB6 IDE's Project-Name Table? It's my understanding that it's limited to 32,767 entries, with the actual size limited only by the 2GB boundary.

    It's also my understanding that Intellisense uses this table for all of its case corrections (well, except for Enumerations, which may not be making it into this Project-Name Table).

    It's also rather unusual that there's only one entry per unique (case insensitive) identifier name (variables, constants, all module names, control names, procedure names, & object names). In other words, if we re-use an identifier name in a different scope, they both get only one entry in the Project-Name Table.

    It's a bit weird how this all works. Apparently, the act of typing a Dim (or Static, or Public, etc), writes (or re-writes) the entries in this Project-Name Table. For instance, here's some interesting code:

    Code:
    
    Option Explicit
    
    Private Sub Form_Load()
    
        Dim form1 As Long   ' Deliberately used all-lower-case.
    
        form1.Height = 6000
        ' Typed the above in as "Form1.Height = 6000" and then watched what happened.
        ' Intellisense forced it to lower-case.
    
    End Sub
    

    Or here's another more obvious one that's basically doing the same thing:

    Code:
    
    Option Explicit
    Dim var1 As Long    ' Typed as "Dim Var1 As Long" <--- Notice upper-case "V".
    '
    
    
    Private Sub Form_Load()
    
        Dim var1 As Long    ' Typed this one as "Dim var1 As Long".
        ' When I hit "Enter" it changed the module-level declaration's case to all-lower.
    
    End Sub
    
    

    Microsoft even has the following somewhat confusing statement, and I believe it's actually recommending this doubling-up:

    If the limit is reached, reuse private identifiers in different modules to limit the number of unique entries to 32K.
    In other words, if we reach the 32K unique identifier limit, they recommend re-using identifier names for which there won't be any over-lapping scoping issues.


    Now, I'm not certain, but I believe I've hit this limit before, although it may have been the Module-Entries Table for which I hit the limit. I'm not certain. It was then that I rather quickly started peeling off major chunks of my primary project and placing them in ActiveX DLLs. Having done that, I've been chugging along just fine for a few years now.

    However, I'd dearly love to know where I stand with respect to some of these limits. I mention the Project-Name Table, but it'd be over-the-moon if I could get information on the status of the Module-Entries Table as well.

    Any Ideas?,
    Elroy
    Last edited by Elroy; Aug 8th, 2018 at 06:08 PM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  2. #2

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: Project-Name Table entries

    I did a little test just to see if the limit actually exists. My test project is attached.

    During testing, I did discover a couple of other things. Apparently, there is a function limit per module. After I added 10920 functions to a module, I couldn't get the 10921'st added without an Out Of Memory error, or some other funky behavior. So, to test, I wound up creating three BAS modules, the first with a Sub Main in it, just to stay away from any forms.

    After I got to 32498 procedures, I was at the end of things and kept getting Out Of Memory errors. It's interesting that it was 32498, and not something a bit closer to 32,767. But maybe VB6 places a few entries in there to get things going. You can see some of my comments on the bottom of Test3.BAS. You can also just try creating another procedure and watch what happens. You can't do it. You can't even declare a module-level variable at the top of Test3.BAS. Apparently the Project-Name Table is just full.

    I'm still looking for a way to access this table to possibly count the entries, and maybe even list/show them. My ideas include a memory scan (which is probably the best way), or possibly a utility that will scan all the source-code files and count them up. However, that second approach would involve considerable thought.

    Take Care,
    Elroy
    Attached Files Attached Files
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  3. #3
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,156

    Re: Project-Name Table entries

    Quote Originally Posted by Elroy View Post
    I'm still looking for a way to access this table to possibly count the entries, and maybe even list/show them.
    I'm wondering what is the purpose of this excercise? Preparing for the future before hitting the limit?

    cheers,
    </wqw>

  4. #4
    gibra
    Guest

    Re: Project-Name Table entries

    Quote Originally Posted by Elroy View Post
    I'm still looking for a way to access this table to possibly count the entries, and maybe even list/show them.
    MZ-Tools v.3 add-in already does this.


    MZ-Tools 3.0 - Productivity Tools for Visual Basic 6.0, 5.0 and VBA
    https://web.archive.org/web/20150206.../mztools3.aspx



    Last edited by gibra; Aug 9th, 2018 at 03:34 AM.

  5. #5

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: Project-Name Table entries

    Quote Originally Posted by wqweto View Post
    I'm wondering what is the purpose of this exercise? Preparing for the future before hitting the limit?
    Exactly. There are other "chunks" of my primary project I could peel off into ActiveX projects. It's just not totally trivial to do that, and it'd be nice to know when I should start planning for it.

    Quote Originally Posted by gibra View Post
    MZ-Tools v.3 add-in already does this.
    Hmmm, in your screen-shot, I'm not seeing it. It's obviously giving a list of modules (and some basic stats about those modules). However, to provide the information about the Project-Name Table, it'd need to go through and count all declarations of "identifiers", which would include the module names, but much more. For me, the main thing it would include is the declaration of every variable with a unique name. My control names would probably also occupy a sizable chunk of that list.

    Just thinking about it, it sure makes me glad I have a habit of doing "Dim i As Long" when I need a quick loop index. Also, when I have a form with lots of labels, I typically create a control array of labels named lblMisc. I bet I've got a lblMisc control array on 100s of forms. Occasionally, I'll just leave it as Label1. I should probably go through and name them all lblMisc to save space in the Project-Name Table.

    I'd still love to have a list of what's in this Project-Name Table (i.e., "identifier" table).
    Last edited by Elroy; Aug 9th, 2018 at 10:30 AM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  6. #6
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,048

    Re: Project-Name Table entries

    Hi Elroy,

    not quit sure what your after, but a .bas is nothing more than a Textfile

    here a sample
    Code:
    Private Sub Command4_Click()
     
       Dim s() As String
       Dim myFile As String
       Dim zw As String
       Dim FNr As Integer
       Dim i As Long
       
          myFile = "c:\Chris\test1.bas"
          FNr = FreeFile
          Open myFile For Binary As #FNr
          zw = Space(LOF(FNr))
          Get #FNr, , zw
          Close #FNr
          
          s = Split(zw, vbCrLf)
          For i = LBound(s) To UBound(s)
             zw = LCase(s(i))
             If Left(zw, 4) = "sub " Or Left(zw, 9) = "function " Then
                List1.AddItem zw
             ElseIf Left(zw, 11) = "public sub " Or Left(zw, 16) = "public function " Then
                List1.AddItem zw
             ElseIf Left(zw, 12) = "private sub " Or Left(zw, 17) = "private function " Then
                List1.AddItem zw
             End If
          Next   
    End Sub
    regards
    Chris
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  7. #7
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Project-Name Table entries

    I bet I've got a lblMisc control array on 100s of forms. Occasionally, I'll just leave it as Label1. I should probably go through and name them all lblMisc to save space in the Project-Name Table.
    How to you figure that will save space label1 is 6 characters lblMisc is 7 characters.

  8. #8

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: Project-Name Table entries

    Quote Originally Posted by ChrisE View Post
    not quit sure what your after, but a .bas is nothing more than a Textfile
    Hi Chris,

    Ohhh, I'm well aware. I just don't look forward to going through them all and working up a list of all the "identifiers". I'm still hoping someone has some ideas on how to directly access the VB6 IDE Project-Name Table (i.e., identifier table), and pull the "identifier" names directly out of it. As I see it, going through and identifying all the identifiers from the source code would be a fair amount of work.

    Quote Originally Posted by DataMiser View Post
    How to you figure that will save space label1 is 6 characters lblMisc is 7 characters.
    Hi Data,

    As I read things, it's not exactly about the length of the "identifiers" (although, ultimately, that will nibble on the 2GB limit while in the IDE), but more about the Count of identifiers. And personally, I like to name all of my controls with a three letter prefix that identifies the control type (lbl, txt, cbo, tre, lst, lsv, etcetera). However, I know that I sometimes get lazy and just leave labels as the Label1, Label2, etcetera. I was just saying that I should always pick a common name (and always use a control array) for labels that don't change/move. This way, they would all (project wide) only take one entry in the Project-Name Table.

    ------------

    Still no ideas on how to directly access this Project-Name Table (i.e., identifier table)? Trick? It's not something you've ever done?

    The best idea I've got to do it (although not even started), is to grab chunks of memory being used by the IDE while a project is loaded. I'm sure that the 2GB limit still applies when in the IDE, so we should be able to figure how what memory to look at.

    And then, we could start looking for a list of our known identifiers (or maybe create a few in the project with unusual names). And then, hope that they're all contiguous in the table, and start gathering them. This also assumes that they're Unicode (which is probably a safe bet).

    Ideally, there'd be some "memory signature" where we could identify the beginning of the table, and then start gathering until we detected some "memory signature" for the end.

    But that's all just whimsical thinking at this point.

    I've got several pieces of code for identifying a VB6 compiled EXE's location in memory (and then grabbing memory chunks). However, I don't think I've ever done that while running in the IDE. I suppose that would be a start.

    Has anyone ever managed to snoop the VB6 IDE's memory?

    Y'all Take Care,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  9. #9

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: Project-Name Table entries

    And upon more testing, apparently each added Component (OCX) added to the project takes exactly one entry in the table. I continued using my Test project (attached to post #2), and attempted to add ComCt332.ocx and also ComCt2.ocx. Each time, it required that I free up one spot in the Project-Name Table for it to be allowed.

    The ComCt2.ocx has five new controls it adds, but, apparently, they don't need Project-Name Table entries. I'm guessing that any ActiveX component maintains its own internal list of "identifiers" and has no need for the active project's Project-Name Table. Although, I'm not sure why the "one entry" is needed ... possibly for the library's name itself (such as MSComCtl2, as when you see "MSComCtl2.DTPicker DTPicker1" when the date picker is used).

    Therefore, each externally referenced library probably takes one Project-Name Table entry, with the rest verified through some kind of Object-Browser mechanism.

    ----

    Hmmm, ok, that made me think about some other stuff. What about declaring API calls, like the following?

    Code:
    
    Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Dest As Any, ByRef Source As Any, ByVal Bytes As Long)
    

    It turns out that requires 4 entries in the Project-Name Table (again validating with my test project). I'm guessing it's "CopyMemory", "Dest", "Source", and "Bytes". This can be somewhat proven by trying to use any of those. They will all automatically case-correct when being used. So, that's something else that must be counted if this must be done by examining source code.

    Take Care,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  10. #10

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: Project-Name Table entries

    I think maybe I've figured out something else as well. I'm starting to think the complete list of Keywords are in the Project-Name Table. Is it possible the complete list of "core" Keywords is ~269? This is the difference between 32498 (where things start to fail for me), and 32767 (the supposed max-count of the table).

    Also, when we create procedures with the same name as a Keyword, they do change things for Intellisense. For instance, start a project with Form1 & Form2. In Form2, place the following code:

    Code:
    
    Option Explicit
    
    Private Function val() As Variant   ' <--- Declared with lower-case "v".
        val = 999
    End Function
    

    And then, in Form1, put the following code:

    Code:
    
    Option Explicit
    
    Private Sub Form_Load()
        MsgBox val("1234")
    End Sub
    

    You'll notice that Intellisense makes the "val" in Form1, all-lower-case. That suggests there's definitely an entry in Project-Name Table, possibly overwriting the original Keyword entry (but not totally sure about that one). It may just be that, during case-correction, the Project-Name Table is checked after the Keyword list. In any event, this is one more consideration for a scan of source-code to gather this list.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  11. #11

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: Project-Name Table entries

    Well, since nobody had any ideas, I hauled off and did it myself. It's not finished, but it's definitely coming together. These are the identifiers I have "identified":

    • Referenced library names
    • Module names
    • Control names
    • API names
    • API variables (arguments)
    • Const declarations
    • Dim declarations
    • Public declarations
    • Private declarations
    • Static declarations
    • Redim declarations
    • Sub names (with all Public, Private, Friend, Static variations)
    • Sub arguments
    • Function names (with all Public, Private, Friend, Static variations)
    • Function arguments
    • Property (Let, Get, Set) names (with all Public, Private, Friend, Static variations)
    • Property arguments
    • Type names
    • Type item names
    • Enum names
    • Enum item names
    • Line label names
    • Field names (eg, rs![SomeField])

    I suppose there are also cases where people use the square brackets for variable names too, but I don't do that. Also, I require that "Option Explicit" be in all the modules, or nothing works correctly.

    I've bolded the ones I've done so far.

    I've also attached where I am. I've taken the approach of reading the VBP file, and then reading the modules listed in it. Everything is read-only, and nothing is done to any source code!

    Now, just to say it, I do make a little registry entry but only on my machine (or any machine that reports the user as "Elroy"). Also, I do place an output text file on your desktop. You'll have to deal with that one (or not mess with it, or comment it out).

    If anyone would like to tell me anything I'm missing, or possibly how something's not working correctly, that'd be really great.

    Also, I'd love to hear how many "identifiers" your various projects are reporting.

    I'm not gathering them all just yet, but I feel confident that I'm gathering the vast majority of them. I'm currently at 13,234 with my primary project. That's quite a few, but far less than the ~32,000 that Microsoft says are allowed. When I saw that number, I took a big sigh of relief.

    Again, I look forward to opinions.

    Elroy

    NOTICE: UPDATE ATTACHED TO POST #17.
    Attached Files Attached Files
    Last edited by Elroy; Aug 10th, 2018 at 01:33 PM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  12. #12
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,156

    Re: Project-Name Table entries

    On line 101 this If iCnt > 1 Then Error 16 bombs on enums like Private Enum Test: Value = (-1): End Enum

    Weird that the first project of mine I test came up with 13236 identifiers :-))

    cheers,
    </wqw>

  13. #13
    Hyperactive Member
    Join Date
    Jun 2016
    Location
    España
    Posts
    508

    Re: Project-Name Table entries

    very interesting for me, I would like to be able to export names of the functions, sub, property, etc and their parameters.
    I have many dll in my project and it would be a way to help people better understand the dll.
    it occurs to me to do as in other languages ​​read the previous rows
    Code:
    '' '<summary>
    '' 'This method adds two numbers
    '' '</ summary>
    '' '<param name = "num1"> First number </ param>
    '' '<param name = "num2"> Second number </ param>
    '' '<remarks> Returns the sum of two numbers </ remarks>
    greetings and forgiveness for the translation

  14. #14
    Hyperactive Member
    Join Date
    Jun 2016
    Location
    España
    Posts
    508

    Re: Project-Name Table entries

    very interesting for me, I would like to be able to export names of the functions, sub, property, etc and their parameters.
    I have many dll in my project and it would be a way to help people better understand the dll.
    it occurs to me to do as in other languages ​​read the previous rows
    Code:
    '' '<summary>
    '' 'This method adds two numbers
    '' '</ summary>
    '' '<param name = "num1"> First number </ param>
    '' '<param name = "num2"> Second number </ param>
    '' '<remarks> Returns the sum of two numbers </ remarks>
    greetings and forgiveness for the translation

  15. #15

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: Project-Name Table entries

    Quote Originally Posted by yokesee View Post
    very interesting for me, I would like to be able to export names of the functions, sub, property, etc and their parameters.
    Hi Yokesee,

    Yeah, I've thought about that before too. Actually, I really see that as a different project though, with different objectives. And, truth be told, I've been at my large primary project for so long (since 1999, and that doesn't even count some older code I folded into it), that I have a pretty good feel for every procedure that's in it. Part of me almost hates saying that, admitting how much a part of my life this thing has been.

    But your idea of listing all the procedures and their arguments (per module) wouldn't be terribly difficult. In fact, you could take my code that reads the VBP file as a starting place, and do it fairly easily.

    Quote Originally Posted by wqweto View Post
    On line 101 this If iCnt > 1 Then Error 16 bombs on enums like Private Enum Test: Value = (-1): End Enum
    I'll take a look at that today and fix it. That's a syntax I've never used. The fact that I'm treating Enums like quasi-function got me into trouble.

    Quote Originally Posted by wqweto View Post
    Weird that the first project of mine I test came up with 13236 identifiers :-))
    I'll be sure to add a handful to mine so it has more.

    Y'all Take Care,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  16. #16
    Addicted Member
    Join Date
    Jun 2018
    Posts
    189

    Re: Project-Name Table entries


  17. #17

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: Project-Name Table entries

    Alrighty, I've now covered all the based I itemized in post #11, and also fixed wqweto's bug.

    I also covered the case where someone might be surrounding their variable names with brackets. Although I didn't cover the case where a variable name may have a space in it. I've never done that (not even with database field names), and think it's a horrible practice.

    The only thing I can think of that I haven't covered is certain library names (TypeLibs, and other DLLs like DAO or ADO). The actual internal names of these libraries (just one entry per library) seem to be in the Project-Name Table. Now, it's not the TypeLib information, just its name. Regarding OCX-type libraries, I've got those covered.

    And, even though these library names aren't covered, at most, for any particular project, it couldn't be more than a handful of "identifiers", so nothing really to worry about in terms of overflowing the Project-Name Table.

    My main project is now reporting 16,067 total identifiers. That's still well below the ~32,000 that Microsoft says can be in there, and the 32,498 I managed to get in there in my testing (see Post #2). So, I'm feeling pretty good. If I've gone 20 years and used only half my space, I'm good to go. Now I'll just worry about the Module-Entries Table. I've read the description of that one several times, but I'm still somewhat confused on how to determine how full it is.

    I'm calling this one resolved. Latest version of the "identifier" gathering/counting code is attached.

    Best Regards,
    Elroy
    Attached Files Attached Files
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  18. #18
    New Member
    Join Date
    Nov 2022
    Posts
    1

    Thumbs up Re: Project-Name Table entries

    Hi Elroy,

    Sorry to resurrect an older post, but considering the topic and the age of the IDE, it's actually one of the most recent forums I have found on the subject!

    We have been battling with the dreaded Out Of Memory errors for a long time now in an MS-Access project of ours, which has grown too big over the years.

    I just wanted to say that it was a delight to stumble upon this post and find someone who, not only had experienced the same issue but also could explain ways to replicate it.

    We didn't know if it was due to database corruption, too many forms, or too many procedures or what was causing it. In fact, we think it might be a combination. We can usually pacify the beast by decompiling and occasionally exporting all objects to text and then reimporting them again, but after you've done this a few times, you start to wonder, how long can this go on for! We need to work out which limit(s) we are breaking consistently so we can stay within it/them.

    We tried using your NameTableTest project in Access and it also generated the same results as VB6, which was good to see.

    I wrote a new project in VB.Net to extract all objects from an Access database and then, using your code, we were able to get it to calculate the Identifiers count.

    We had to modify your code slightly as we have form names with spaces and hyphens and these are referred to in the code with square brackets. Very ugly.

    Interestingly, although we are able to get a count of the Identifiers, it came in high at 36,644 so I am now more confused than ever as to how we have ever wrestled it into compiling!

    Regards,

    Rawden.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width