Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Components
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VB Components Issues specific to components in VB.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Components section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 12th, 2004, 01:51 AM
Registered User
 
Join Date: Feb 2004
Location: Chennai, Tamilnadu, India.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default list of all controls within a .frm file

Hi,

I want to create an application where in I give the name of a .VBP file and the application should list me the list of all controls within a .frm file or files and all the events present in the .frm file.

Reply With Quote
  #2 (permalink)  
Old February 12th, 2004, 11:44 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Sparks, NV, USA.
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jlick
Default

Thank you for sharing your application idea. Did you have any questions or requests?

John R Lick
JohnRLick@hotmail.com
Reply With Quote
  #3 (permalink)  
Old February 12th, 2004, 09:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Two ways to do it, as I see it.
First, read the vbp or the frm as ascii text, and parse it (as I do)
Second, write it as an add-in.
Marco
Reply With Quote
  #4 (permalink)  
Old February 12th, 2004, 10:54 PM
Registered User
 
Join Date: Feb 2004
Location: Chennai, Tamilnadu, India.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

HI,
   I somehow completed the application but it shows the count for only one form and not all the forms. The pattern I am following is I am picking up the VBP file using a Common Dialog and then using DIRlist.Count i am checking for all the .frm files in the that path.. I read the file in to a text file and then parse it looking ofr the word "Begin VB." since when 3rd party controls are inserted into the the VB part does not appear so on the whole i am using the keyword "Begin" parse thru the file....

My code is given below


Option Explicit

Private Sub Command1_Click()
Dim iFreeFile, iFreeFile2 As Integer
Dim Dirlist As New Collection
Dim i, fcnt, mcnt, ucnt, ccnt, vbctlcnt As Integer
Dim Dirpath, sPath, spath2, sstrline, sstrline2 As String
Dim Strsplit

CommonDialog1.ShowOpen
sPath = CommonDialog1.FileName

Strsplit = Split(sPath, "\")

For i = LBound(Strsplit) To UBound(Strsplit) - 1
Dirpath = Dirpath & Strsplit(i) & "\"
Next i

fcnt = 0
mcnt = 0
ucnt = 0
vbctlcnt = 0

iFreeFile = FreeFile()

Open sPath For Input As iFreeFile
While Not EOF(iFreeFile)
    Line Input #iFreeFile, sstrline
    Select Case Left(sstrline, 4)
    Case "Form" ' Count the forms
        fcnt = fcnt + 1
        Dirlist.Add (Mid(sstrline, 6))
    Case "Modu" ' Count the Modules
        mcnt = mcnt + 1
    Case "Clas" ' Count the Classes
        ccnt = ccnt + 1
    Case "Cont" ' Count the UserControls
        ucnt = ucnt + 1
    End Select
Wend

Debug.Print "No of Forms = " & fcnt
Debug.Print "No of Modules = " & mcnt
Debug.Print "No of Classes = " & ccnt
Debug.Print "No of User Controls = " & ucnt

Close #iFreeFile


' Count the countrols in the form
iFreeFile2 = FreeFile()
For i = 1 To Dirlist.Count
spath2 = Dirpath & Dirlist.Item(i)
Open spath2 For Input As #iFreeFile2
While Not EOF(iFreeFile2)
Line Input #iFreeFile2, sstrline2
If Left(Trim(sstrline2), 6) = "Begin " Then
vbctlcnt = vbctlcnt + 1
End If
Wend
Debug.Print "Count for " & Dirlist.Item(i) & " = " & vbctlcnt
vbctlcnt = 0
sstrline2 = ""
Close #iFreeFile2
iFreeFile2 = FreeFile()
Next i
End Sub

Can anyone of you help so that given a VBP file it will list all the controls in as many form present aloing with the form names..

One more addition cud be that i give the folder path where the VB files exist. There cud be multiple VBP files it has to take the VBP file scan thru the form under the particular VBP list the count of all the Controls, UserControls, Forms, Modules, and Classes and the move on to the next VBP file and do the same until no mor VBP files are present.

If anyone can provide the code I will be obliged

Thanks
Arvind

Reply With Quote
  #5 (permalink)  
Old February 13th, 2004, 05:48 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear Arvind,
First, the is one basic mistake in your code: unlike C, each variable must declared with its type, even in a single line. For example, the line:
 Dim iFreeFile, iFreeFile2 As Integer
defines iFreeFile as a Variant. The same line should be
 Dim iFreeFile as Integer, iFreeFile2 As Integer

In your code, vbctlcnt counts only one form because it is always sets to zero. If you want both a local count (for each form) and a global count (for all forms) then you need an extra variable lTotalCount and increment it before setting vbctlcnt to zero:
lTotalCount = lTotalCount + cvctlcnt
As form multiple vpb, put your code in a method and pass to it the path of a .vbp file. To get all vbp files in a folder, use the Dir statement
dim ss as String
ss = dir(mypath & "*.vbp)
while len(ss) > 0
  ProcessVBP ss
  ss = Dir
wend

Marco
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Try it Out List Controls phage BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 6 September 15th, 2008 02:15 PM
Ch8 - TIO#4 (Other List Controls) jecii BOOK: Beginning ASP.NET 2.0 and Databases 0 December 7th, 2007 07:57 PM
ASP List Controls rsearing ASP.NET 2.0 Basics 0 September 25th, 2006 09:44 PM
Open & save 1 frm witout closing the prvs frm anukagni Access 3 January 10th, 2006 02:42 AM
Data Binding to List Controls dejawoo ASP.NET 1.0 and 1.1 Professional 2 July 3rd, 2004 10:54 PM



All times are GMT -4. The time now is 10:15 PM.


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