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