统计代码行的源程序
时 间:2004-12-23 00:00:00
作 者:竹笛 ID:8 城市:上海 QQ:2851379730
摘 要:统计代码行的源程序
正 文:
当您有开发完一个作品时,也许你希望知道你的代码写了多少行,这时你可以使用下面的代码来统计它,不过有些耗时,我统计了一下我开发的一个软件,共8108行,运行了近20分钟:-D
在你的程序中新增一模块,命名为:mdlCountLines,并复制下面的代码到该模块中:
Public Function fCountLines() As Long
' Code to count the number of lines of code in the current database
On Error GoTo E_Handle
Dim db As Database
Dim ctr As Container
Dim doc As Document
Dim frm As Form
Dim rpt As Report
Dim mdl As Module
Dim lngCount As Long
Dim intCount As Integer, intLoop As Integer
Set db = CurrentDb
Set ctr = db.Containers!Forms
For Each doc In ctr.Documents
DoCmd.OpenForm doc.Name, acDesign, , , , acHidden
Set frm = Forms(doc.Name)
If frm.HasModule = True Then
Set mdl = frm.Module
intCount = mdl.CountOfLines
For intLoop = 1 To intCount
If Len(mdl.Lines(intLoop, 1)) > 0 And Left(Trim(mdl.Lines(intLoop, 1)), 1) <> "'" Then
lngCount = lngCount + 1
End If
Next intLoop
Set mdl = Nothing
End If
DoCmd.Close acForm, doc.Name
Set frm = Nothing
Next doc
Set ctr = db.Containers!Reports
For Each doc In ctr.Documents
DoCmd.OpenReport doc.Name, acViewDesign
Set rpt = Reports(doc.Name)
If rpt.HasModule = True Then
Set mdl = rpt.Module
intCount = mdl.CountOfLines
For intLoop = 1 To intCount
If Len(mdl.Lines(intLoop, 1)) > 0 And Left(Trim(mdl.Lines(intLoop, 1)), 1) <> "'" Then
lngCount = lngCount + 1
End If
Next intLoop
Set mdl = Nothing
End If
DoCmd.Close acReport, doc.Name
Set mdl = Nothing
End If
Next doc
fCountLines = lngCount
fExit:
On Error Resume Next
Set ctr = Nothing
Set db = Nothing
Exit Function
E_Handle:
MsgBox Err.Description & vbCrLf & "fCountLines", vbOKOnly + vbCritical, "Error: " & Err.Number
Resume fExit
End Function
Access软件网QQ交流群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 【Access选项卡示例】Ac...(09.09)
- 【Access源码示例】按输入...(09.02)
- 【Access日期区间段查询】...(08.29)
- 【Access日期区间段查询】...(08.27)
- Access怎样才能实现日期时...(08.21)
- 【Access定时打开查询】A...(08.19)
- Access生成固定数量的记录...(08.13)
- Access怎样才能实现日期时...(08.12)
- Access利用导航窗体控件对...(08.03)
学习心得
最新文章
- Access表中的字段名、字段标题...(09.19)
- Access快速开发平台--更改“...(09.18)
- 【中秋及国庆优惠】Access培训...(09.15)
- Access如何将日期型的数值转换...(09.14)
- 英文输入法输入数据中存在单引号引起...(09.11)
- 【Access选项卡示例】Acce...(09.09)
- 让Access光标停留在指定的控件...(09.07)
- 关于Access查询条件里使用通配...(09.06)
- Access报表偷懒制作法--Ac...(09.05)
- Access快速开发平台--窗体数...(09.04)