View Single Post
  #5 (permalink)  
Old July 16th, 2007, 08:30 AM
mmcdonal mmcdonal is offline
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

This code returns 19 from your sample text file:

sFile = "C:\SampleCodeFile.txt"


Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(sFile) Then
    Set objFile = objFSO.OpenTextFile(sFile, 1)
    Do Until objFile.AtEndOfStream
        sLine = objFile.ReadLine
        iComment = InStr(sLine, "*")
        If iComment = 0 Then
            iCount = iCount + 1
        End If
    Loop
End If

iCount = 19.

Are you using DAO or ADO to add this to a table? I use ADO so would do this:

sSQL = "SELECT * FROM tblMyTextCounterTable"

Set rs = New ADODB.Recordset
rs.Open sSQL, CurrentProject.Connection, adOpenDynamic, adLockOptimistic

rs.AddNew
rs("FileNameAndPath") = sFile
rs("LinesOfCode") = iCount
rs.Update

rs.Close




mmcdonal
Reply With Quote