VBE CountOfLines...

Discussion in 'AutoCAD' started by Matt W, Jan 12, 2005.

  1. Matt W

    Matt W Guest

    I'm trying to write a little program that will count the number of lines in
    any sub, function, etc... but I can't seem to figure out the CountOfLines
    portion.
    Right now, it's giving me a count of ALL of the lines of code.

    Here's what I've got so far...

    Sub TEST()
    Dim objVBE As VBIDE.VBE
    Dim objProc As String
    Dim lngSL As Long, lngSC As Long, lngEL As Long, lngEC As Long
    Set objVBE = ThisDrawing.Application.VBE
    Debug.Print objVBE.ActiveCodePane.CodeModule
    objVBE.ActiveCodePane.GetSelection lngSL, lngSC, lngEL, lngEC
    objProc = objVBE.ActiveCodePane.CodeModule.ProcOfLine(lngSL,
    vbext_pk_Get)
    Debug.Print objProc
    Debug.Print objVBE.ActiveCodePane.CodeModule.CountOfLines
    Set objVBE = Nothing
    End Sub

    Thanks in advance!
     
    Matt W, Jan 12, 2005
    #1
  2. Matt W

    fantum Guest

    Try

    Debug.Print objVBE.ActiveCodePane.CodeModule.ProcCountLines(objProc, vbext_pk_Get)
     
    fantum, Jan 12, 2005
    #2
  3. Matt W

    Matt W Guest

    No dice.
    I get RT Error 35 "No Sub of Function Defined".
     
    Matt W, Jan 12, 2005
    #3
  4. Matt W

    Matt W Guest

    Figured it out...
    It should be Debug.Print
    objVBE.ActiveCodePane.CodeModule.ProcCountLines(objProc, vbext_pk_Proc)
    instead.
     
    Matt W, Jan 12, 2005
    #4
  5. Matt W

    fantum Guest

    Unless you want the line count of a property procedure.
     
    fantum, Jan 12, 2005
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.