473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

How many lines of code do I have?

1,287 Expert 1GB
I was just asked an interesting question: How many lines of vba code do I have in my Access project?

I didn't see any easy way to get this from the editor, and I don't know if it's possible to access the code in text form outside of Access. Anyone have a suggestion?
Dec 8 '09 #1

✓ answered by Stewart Ross

Hi Chip. Investigate the use of the VBComponents collection of the Application.VBE object which is built-in to Access.

For example, the following sub will list the names of the code modules in your current project and the number of lines in each to the immediate window:

Expand|Select|Wrap|Line Numbers
  1. Public Sub ModuleInfo()
  2.     Dim basModule As VBComponent
  3.     For Each basModule In Application.VBE.ActiveVBProject.VBComponents
  4.         With basModule
  5.           Debug.Print .Name, .CodeModule.CountOfLines, .CodeModule.CountOfDeclarationLines
  6.         End With
  7.     Next basModule
  8. End Sub
-Stewart

4 16472
missinglinq
3,532 Expert 2GB
The MZ-Tools addin (freeware) offers a lot of documentation options, including, I believe, the total lines of code for an app.

http://www.mztools.com/index.aspx

Linq ;0)>
Dec 8 '09 #2
ChipR
1,287 Expert 1GB
Thanks for the link, Linq :)
That looks like a nice option. Unfortunately for me, I can't use any unapproved programs, and approval takes a long time (from what I hear). Is there any way to get to my Access code in Visual Studio?
Dec 8 '09 #3
Stewart Ross
2,545 Expert Mod 2GB
Hi Chip. Investigate the use of the VBComponents collection of the Application.VBE object which is built-in to Access.

For example, the following sub will list the names of the code modules in your current project and the number of lines in each to the immediate window:

Expand|Select|Wrap|Line Numbers
  1. Public Sub ModuleInfo()
  2.     Dim basModule As VBComponent
  3.     For Each basModule In Application.VBE.ActiveVBProject.VBComponents
  4.         With basModule
  5.           Debug.Print .Name, .CodeModule.CountOfLines, .CodeModule.CountOfDeclarationLines
  6.         End With
  7.     Next basModule
  8. End Sub
-Stewart
Dec 8 '09 #4
ChipR
1,287 Expert 1GB
Perfect! I knew there had to be a way, just never heard of that collection.
Thanks, Stewart.
Dec 8 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: Alex Vinokur | last post by:
Is there any tool to count C-program lines except comments? Thanks, ===================================== Alex Vinokur mailto:alexvn@connect.to http://mathforum.org/library/view/10978.html...
33
by: Xah Lee | last post by:
The Harm of hard-wrapping Lines 20050222 Computing Folks of the industry: please spread the debunking of the truncating line business of the fucking unix-loving fuckheads, as outlines here:...
10
by: Craig Bumpstead | last post by:
Hi, I was wondering the best and fastest way to determine how many lines are in a log file. At the moment I am simply doing a StreamReader.ReadLine and incrementing a counter until I reach...
5
by: Brian | last post by:
Hello all.. Am working on an Air Hockey game... have an table loaded into a picture box. The borders of the table are slightly slanted. Am using hit testing lines with GDI+ to manipulate the...
54
by: MLH | last post by:
I use A97 and do not always insert line numbers while writing procedures. I find it necessary to go back and add them later to aid in debugging. Nearly 3 years ago, something was mentioned in...
2
by: m00nm0nkey | last post by:
Ok well i thought i'd try a different approach, so what I'm now trying is appending 50,000 lines from the collection to a stringbuilder, and then writing that entire stringbuilder to a file. ...
82
by: Edward Elliott | last post by:
This is just anecdotal, but I still find it interesting. Take it for what it's worth. I'm interested in hearing others' perspectives, just please don't turn this into a pissing contest. I'm in...
11
by: Girish Sahani | last post by:
I wrote the following code to concatenate every 2 keys of a dictionary and their corresponding values. e.g if i have tiDict1 = tiDict1 = {'a':,'b':} i should get tiDict2={'ab':} and similarly for...
19
by: Pavan | last post by:
Hi, I want to know if there is any software for measuring lines of code of my c++ application. I found out a tool, sloccount, but it gives only physical lines of code. I found out one more...
7
by: Gustaf | last post by:
Hi all, Just for fun, I'm working on a script to count the number of lines in source files. Some lines are auto-generated (by the IDE) and shouldn't be counted. The auto-generated part of files...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.