Results 1 to 2 of 2

Thread: [RESOLVED] Count files

  1. #1

    Thread Starter
    Lively Member elmnas's Avatar
    Join Date
    Jul 2009
    Posts
    127

    Resolved [RESOLVED] Count files

    Hello People I made this code

    Could someone help me make an alert to show in the end how many files are modified?

    See code:
    Code:
    Public Class SdlStudioChanger
    
        Private Sub BT_Browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT_Browse.Click
    
            ' Set Folder PATH default
            FolderBrowserDialog1.SelectedPath = My.Computer.FileSystem.SpecialDirectories.MyDocuments
    
            ' Show the new folder button
            FolderBrowserDialog1.ShowNewFolderButton = True
    
            If FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
                ' Get the full path to the file that selected by the user.
                Dim mySelFile As String = FolderBrowserDialog1.SelectedPath
    
    
    
    
                ' Displays the full path of the file selected by the user in the box (TextBox)
                Tb_FilePath.Text = mySelFile
    
                'Displays the folder name (only) selected, the user"Subtlety, use the" IO.Path.GetFileName "on the path to a folder
                'To get the name of the target folder.
                'While "IO.Path.GetDirectoryName" would have shown you the folder path CONTAINING file
                'Targeted by the specified path as a parameter
                'MsgBox("Du har valt: " & IO.Path.GetFileName(mySelFile))
    
            
    
                    For Each filename As String In IO.Directory.GetFiles(mySelFile, "*.xml")
    
    
    
    
    
                        Dim analyse
                        Dim exactContexts
                        Dim subnode
                        Dim repeated
                        Dim realRepeated
                        Dim tmpValue As String = ""
                        Dim contextModified As Integer = 0
                        Dim repeatModified As Integer = 0
    
    
                        analyse = CreateObject("Msxml2.DOMDocument.6.0")
                        analyse.Load(filename)
    
                        exactContexts = analyse.SelectNodes("//inContextExact")
    
                        For i = 0 To exactContexts.Length - 1
                            subnode = exactContexts(i)
                            For Each att In subnode.Attributes
                                If att.Name = "words" Then
                                    att.Value = "0"
                                    Exit For
                                End If
                            Next att
                        Next i
    
                        repeated = analyse.SelectNodes("//crossFileRepeated")
    
                        For i = 0 To repeated.Length - 1
                            subnode = repeated(i)
                            For Each att In subnode.Attributes
                                If att.Name = "words" Then
                                    tmpValue = att.Value
                                    If att.Value <> 0 Then contextModified = contextModified + 1
                                    att.Value = "0"
                                    Exit For
                                End If
                            Next att
    
                            realRepeated = subnode.NextSibling
                            For Each att In realRepeated.Attributes
                                If att.Value <> 0 Then repeatModified = repeatModified + 1
                                If att.Name = "words" Then
                                    att.Value = Val(att.Value) + Val(tmpValue)
                                    Exit For
                                End If
                            Next att
                        Next i
    
    
                        analyse.Save(filename)
    
                    Next
    
    
    
    
                Else
    
                    'if the user has not selected a folder, it is a warning
                    MsgBox("Ingen fil vald", MsgBoxStyle.Exclamation, "Inga markerade mappar")
                End If
    
    
            End If
    
    
        End Sub
    Thank you in advance VB Members
    Last edited by elmnas; Jun 2nd, 2015 at 02:59 AM.

  2. #2
    Lively Member
    Join Date
    May 2015
    Posts
    111

    Re: [RESOLVED] Count files

    I'm by no means an expert at this, but this is what I would do. There could very well be a better, faster way to do it.

    Dim intChangeCounter as Integer

    [The code where you make changes]
    intChangeCounter = intChangeCounter + 1

    [Once you are ready to display message box:]
    Msgbox "You made " & intChangeCounter & " changes"

    Hopefully that is what you were looking to do.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width