我的问题是个逆归问题,问题如下:Private Sub Form_Load()
On Error GoTo hackate
    
    ListView1.ColumnHeaders.Add 1, , "文件名", 2700
    ListView1.ColumnHeaders.Add 2, , "行  数", 1300
    ListView1.ColumnHeaders.Add 3, , "大  小", 1300
    ListView1.ListItems.Clear
    i = 1
    'Set objsj = oFSO.GetFolder("F:\Program Files\NetBox 2.7\WWW\shesh\")
    For Each oFile In objsj.Files
        If LCase(Right$(oFile, 4)) = ".asp" Or LCase(Right$(oFile, 4)) = ".asa" Or LCase(Right$(oFile, 4)) = ".ini" Or LCase(Right$(oFile, 4)) = ".htm" Or LCase(Right$(oFile, 4)) = ".html" Or LCase(Right$(oFile, 4)) = ".css" Or LCase(Right$(oFile, 4)) = ".js" Then
            'Len(oFile.Size) < 1048576
            abc = GetLineCount(oFile)
            cbc = cbc + abc
            
    ListView1.ListItems.Add , , oFile.Name
    ListView1.ListItems(i).ListSubItems.Add , , GetLineCount(oFile)
    ListView1.ListItems(i).ListSubItems.Add , , GetSize(oFile.Size)        i = i + 1
        End If
    Next
    Text1.Text = "该文件夹ASP代码总行数为:" & vbCrLf & vbCrLf & cbc & " 行"
    Exit Sub先告诉大家,我这个是计算出我的一个文件夹内的.asp的后缀的文件他的行数啊!因为如果用
软件一个一个看ASP文件的行数的话,要计算一个目录可见多麻烦,我是做了这个来计算的!
可是我根本不懂逆归,比如这个文件夹里面还有文件夹的话那可不知道怎么办了,听说逆归可以
解决问题,请你们务必帮帮我好吗?就我这个代码,帮我写一下逆归的代码好吗?我在这里谢
过了,这个代码真的很急的!!!

解决方案 »

  1.   

    递归的思想是当folder里没有subfolder的时候开始返回,
    具体要看你希望得到什么结果了
    算法不难的
      

  2.   

    来,我贴个关键的,hohoFor Each olistitem In ListView1.ListItems
        j = j + CLng(olistitem.SubItems(1))
    Next
      

  3.   

    '生成指定类别的链表字符串
    '参数:GoodsTypeID:指定的ID
    '返回值:用递归方法生成的字符串
    Public Sub GoodTypeString(GoodsTypeID As Integer, ByRef sTmp As String)
        Dim strSql As String
        Dim Rst As New ADODB.Recordset
        strSql = "select goodstype_id,goods_type,parent_type " & _
                " from t_goodtype_std where goodstype_id=" & _
                GoodsTypeID
        Set Rst = ExecuteSQL(strSql)
        If Rst.EOF = False Then
            If sTmp <> "" Then
                sTmp = Rst!goods_type & "-" & sTmp
            Else
                sTmp = Rst!goods_type
            End If
            If IsNull(Rst!parent_type) = False Then
                Call GoodTypeString(CInt(Rst!parent_type), sTmp)
            End If
        End If
    End Sub来个刚写过的函数.