Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
| Search | Today's Posts | Mark Forums Read
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 24th, 2003, 05:57 PM
Registered User
 
Join Date: Jun 2003
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default VBComponents class in VBIDE (add-in)

<div align="left">Hi,

I am designing an add-in which requires me to loop through all the modules in a VB project and apply functions to them. I have not been able to find any examples of code that do this, so this has been my best guess. I also have not found a good way to debug add-ins, so I have to constantly compile the dll each time and then open up a new instance of VB to run it, however I still am unable to debug the add-in. Any ideas? Ok, back to the code. I placed msgbox's displaying the names of the components in the project as it loops through them and it appears to be looping through all of them, however I'm not sure if I am missing some code since the function is only being applied to 2 out of 10 modules. Could this be a problem with my function or this code that selects the modules and activates them?

Code:
Set Proj = .ActiveVBProject
Set Comp = Proj.VBComponents

TotalModules = .ActiveVBProject.VBComponents.Count
MsgBox "There is a total of " & TotalModules & " modules"

For Each Comp In Proj.VBComponents
   'Activate new module
    Set Pane = Comp.CodeModule.CodePane
    Pane.Show

' lock screen from updating
LockWindow True, , .MainWindow.Caption
' get the starting procedure line count

HeaderCount = .ActiveCodePane.CodeModule.CountOfDeclarationLines
' set us at the starting procedure
.ActiveCodePane.SetSelection HeaderCount + 1, 1, HeaderCount + 1, 1
' show progress
frmInfo.ResetProgressBar
frmInfo.Show
frmInfo.Refresh
Do Until Counter > .ActiveCodePane.CodeModule.CountOfLines
    ' find out what line we are at
    .ActiveCodePane.GetSelection TempStartLine, TempStartColumn, TempEndLine, TempEndColumn
    ' find out where the next procedure is and get the current procedure info
    NextMemberLineStart = GetMemberInfo(TempStartLine)
    ' do what has been selected by user

    Select Case ButtonCaption
        Case "Comment All Procedures"
        ' add comment separators to all procedures
        frmInfo.ProgressMessage "Now adding comments to all procedures", "Comment All Procedures"
        NextMemberLineStart = AddComments(ProcName, ProcType, ProcComment)
        frmInfo.UpdateProgressBar TempStartLine - HeaderCount, .ActiveCodePane.CodeModule.CountOfLines - HeaderCount
        'Exit Do
        Case "Indent All Procedures"
        ' indent all code in current module
        frmInfo.ProgressMessage "Now indenting all procedures", "Indenting All Procedures"
        IndentCode ProcBodyStartLine, ProcBodyEndLine
        frmInfo.UpdateProgressBar TempStartLine - HeaderCount, .ActiveCodePane.CodeModule.CountOfLines - HeaderCount
        'Exit Do
        Case "Spell Check - Quotes and Comments"
        ' spell check quotes and comments in current code module
        SpellCheck
        'Exit Do
        Case "Add Line Numbers"
        ' remove old line numbers, reindent the code and add new line numbers
        frmInfo.ProgressMessage "Now adding line numbers to all procedures", "Add Line Numbers To All Procedures"
        RemoveLineNumbers ProcBodyStartLine, ProcBodyEndLine
        IndentCode ProcBodyStartLine, ProcBodyEndLine
        AddLineNumbers ProcBodyStartLine, ProcBodyEndLine
        frmInfo.UpdateProgressBar TempStartLine - HeaderCount, .ActiveCodePane.CodeModule.CountOfLines - HeaderCount

        Case "Remove Line Numbers"
        ' remove old line numbers and reindent the code
        frmInfo.ProgressMessage "Now removing line numbers from all procedures", "Remove Line Numbers From All Procedures"
        RemoveLineNumbers ProcBodyStartLine, ProcBodyEndLine
        IndentCode ProcBodyStartLine, ProcBodyEndLine
        frmInfo.UpdateProgressBar TempStartLine - HeaderCount, .ActiveCodePane.CodeModule.CountOfLines - HeaderCount

    End Select
    ' set us at the starting line of the next procedure
    .ActiveCodePane.SetSelection NextMemberLineStart, 1, NextMemberLineStart, 1
    ' increment our line counter
    Counter = NextMemberLineStart
Loop

  Pane.Window.Close
'loop through code modules
Next Comp

' hide progressbar
frmInfo.Hide
' unlock screen for updating
LockWindow False, , .MainWindow.Caption
Any example code/suggestions would be appreciated.

Thanks :)</div id="left">
  #2 (permalink)  
Old June 25th, 2003, 09:10 AM
Authorized User
 
Join Date: Jun 2003
Location: , Quebec, Canada.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, I don't know if there is a problem with you code, but I know how you can debug your add-in.

1- Compile your add-in with the compatibility on. (Doesn't matter if it's project or binary)
2- Close all your VB project.
3- Open the Add-in project.
4- Run the Add-in project.
5- Open the test project for the Add-in.
6- You should be able to debug your Add-in. You can put Breakpoint in your Add-in and debug it.

Hope it help you find your problem.

Stéphane


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can’t add method to class in C#? arbab BOOK: Beginning C# 2005 Databases 0 September 29th, 2008 07:35 AM
How to add Windows Forms with Class Designer? chobo2 C# 2008 aka C# 3.0 3 September 15th, 2008 11:00 AM
Adding to a class library using the List..Add BigJay86 C# 2 June 23rd, 2006 04:08 PM
How to add Stub Class in JBuilder vahid1983 J2EE 0 February 14th, 2006 04:53 AM
add new class eagertolearn Visual C++ 0 August 18th, 2003 08:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.