Results 1 to 14 of 14

Thread: Library not found....

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2004
    Location
    Morgan Town
    Posts
    30

    Resolved Library not found....

    Hi,

    I have a module for finding the files of any * extension...I need to call the function in my program....The module has Right$ function in its code..When I try to run the program I get a compilation error saying "Can't find project or library"..The error highlights the Right$ function in the module...I am not sure what library I need to add to the project references..I believe that this is a simple problem but I am unable to figure it out...

    Somebody PLZZZZ help me with this....

    Thanks a lottt...
    Silpa
    Last edited by silpaparnandi; Oct 9th, 2004 at 12:59 PM.
    Silpa Parnandi
    Masters in Electrical Engg
    West Virginia University

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    post your code. you may not have public variables, or something easy like that

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2004
    Location
    Morgan Town
    Posts
    30
    Hi,

    I am attaching the module and the code...

    Thanks,
    Silpa
    Attached Files Attached Files
    Silpa Parnandi
    Masters in Electrical Engg
    West Virginia University

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    I'll try to save it...

    nope.

    copy and paste it into a reply, and surround it with (code) (/code) tags, but use [] instead of ()

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Sep 2004
    Location
    Morgan Town
    Posts
    30
    Hi,

    I am copying the code and pasting it....Following is the code in the module....

    '//*********************************//'
    Public Const MAX_PATH = 260
    Private Const INVALID_HANDLE_VALUE = -1
    Private Const FILE_ATTRIBUTE_DIRECTORY = &H10

    Private Type FILETIME
    dwLowDateTime As Long
    dwHighDateTime As Long
    End Type

    Private Type WIN32_FIND_DATA
    dwFileAttributes As Long
    ftCreationTime As FILETIME
    ftLastAccessTime As FILETIME
    ftLastWriteTime As FILETIME
    nFileSizeHigh As Long
    nFileSizeLow As Long
    dwReserved0 As Long
    dwReserved1 As Long
    cFileName As String * MAX_PATH
    cAlternate As String * 14
    End Type

    Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
    Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
    Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long

    Public Sub FindFiles(strRootFolder As String, strFolder As String, strFile As String, colFilesFound As Collection)

    '*********************************************************
    '* Author: Dragon <sebastian.strand@pp.inet.fi> *
    '* http://personal.inet.fi/cool/dragon/vb/ *
    '* *
    '* Last updated: August 14, 1998 *
    '* *
    '* This recursive routine searches for a specified *
    '* file/files starting from a specified rootfolder *
    '* You can specify folder and file info with pattern *
    '* matching (*, ?, # and so on). For more info on *
    '* pattern matching please refer to the VB documentation *
    '* for the 'Like' function *
    '* *
    '* This function has the following arguments: *
    '* *
    '* strRootFolder = the folder from which the search *
    '* starts. The search will only find *
    '* files in this directory or it's *
    '* subdirectories *
    '* *
    '* strFolder = folder information for the files *
    '* searched. Specify * to allow files in *
    '* any folder. Pattern matching allowed. *
    '* *
    '* strFile = the filename to search for. Pattern *
    '* matching allowed. *
    '* *
    '* colFilesFound = the files found will be placed in *
    '* this collection *
    '* *
    '* Example usage: *
    '* Dim colFiles as New Collection 'Note 'New' keyword!! *
    '* Call FindFiles("C:\Windows\System","*","doc[123].txt")*
    '* *
    '* Then colFiles will be filled with all the text files *
    '* named doc1.txt or doc2.txt or doc3.txt in the Windows\*
    '* System dir and all it's subdirs. *
    '* *
    '*********************************************************

    Dim lngSearchHandle As Long
    Dim udtFindData As WIN32_FIND_DATA
    Dim strTemp As String, lngRet As Long

    'Check that folder name ends with "\"
    If Right$(strRootFolder, 1) <> "\" Then strRootFolder = strRootFolder & "\"

    'Find first file/folder in current folder
    lngSearchHandle = FindFirstFile(strRootFolder & "*", udtFindData)

    'Check that we received a valid handle
    If lngSearchHandle = INVALID_HANDLE_VALUE Then Exit Sub

    lngRet = 1

    Do While lngRet <> 0

    'Trim nulls from filename
    strTemp = TrimNulls(udtFindData.cFileName)

    If (udtFindData.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY Then
    'It's a dir - make sure it isn't . or .. dirs
    If strTemp <> "." And strTemp <> ".." Then
    'It's a normal dir: let's dive straight
    'into it...
    Call FindFiles(strRootFolder & strTemp, strFolder, strFile, colFilesFound)
    End If
    Else
    'It's a file. First check if the current folder matches
    'the folder path in strFolder
    If (strRootFolder Like strFolder) Then
    'Folder matches, what about file?
    If (UCase(strTemp) Like UCase(strFile)) Then
    'Found one!

    colFilesFound.Add strRootFolder '& strTemp

    End If
    End If
    End If

    'Get next file/folder
    lngRet = FindNextFile(lngSearchHandle, udtFindData)

    Loop

    'Close find handle
    Call FindClose(lngSearchHandle)

    End Sub

    Public Function TrimNulls(strString As String) As String

    Dim l As Long

    l = InStr(1, strString, Chr(0))

    If l = 1 Then
    TrimNulls = ""
    ElseIf l > 0 Then
    TrimNulls = Left$(strString, l - 1)
    Else
    TrimNulls = strString
    End If

    End Function


    The following is the code in the form where I need to get the files of .csv extension....

    Private Sub Command1_Click()

    MsgBox "Finding Files of .csv extension in the specified path"
    Dim colFiles As New Collection 'Note 'New' keyword!! *
    Call FindFiles(Text1.Text, "*", "Cat.csv", colFiles)


    End Sub

    I want all the .csv files in the specified path to be stored in the colfiles collection when I click on the command button...

    Hope this helps u to have a better idea of what I need...

    Thanks a lottt ....

    Silpa
    Silpa Parnandi
    Masters in Electrical Engg
    West Virginia University

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    where is the error? have you stepped through the code to make sure that the variables have what you expect them to have when you need them to?

    now, add the code tags that I mentioned earlier, and others will be able to help better. (Code) before and (/Code) after. Replace the () with []. Vbf won't let me enter it any other way. It'll think I want to specify CODE!

    and, take your emal info out of posts, unless you want to get spammed. bots search the forums, and load them into search engines.
    Last edited by dglienna; Oct 5th, 2004 at 01:21 AM.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Sep 2004
    Location
    Morgan Town
    Posts
    30
    hi david,

    This is what I understood by your mail...I am pasting the code and hope I am doing it correct this time..If not I am really sorry for irritating you...This is the first time I am posting a thread in the forums and I am not aware of many things....

    There is no error in the module as such...But when I try to access the module, it shows some error messages..When I comment the lines in the code which has 'Ucase' function, 'TrimNulls' function and "Right$' function,there is no error message. What I can get from the code is that when I try to find the files in the directory with some specific name all the files should be stored in the collection I define..I dont see that happen..I dont understand what the 'FindFiles' function returns and how should I access the data in the collection.

    Regarding taking the email info out of posts, I didnt get what u said.Can u plz be more clear about it as definitely I dont want to get spammed...

    Huh!!! very long mail...Plz dont mind to read it and I hope u can help me this time.....

    THANKS a LOTTTT.....

    Silpa


    CODE:

    '//*********************************//'

    Code:
    Public Const MAX_PATH = 260
    Private Const INVALID_HANDLE_VALUE = -1
    Private Const FILE_ATTRIBUTE_DIRECTORY = &H10
    
    Private Type FILETIME
       dwLowDateTime As Long
       dwHighDateTime As Long
    End Type
    
    Private Type WIN32_FIND_DATA
       dwFileAttributes As Long
       ftCreationTime As FILETIME
       ftLastAccessTime As FILETIME
       ftLastWriteTime As FILETIME
       nFileSizeHigh As Long
       nFileSizeLow As Long
       dwReserved0 As Long
       dwReserved1 As Long
       cFileName As String * MAX_PATH
       cAlternate As String * 14
    End Type
    
    Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
    Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
    Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long
    
    Public Sub FindFiles(strRootFolder As String, strFolder As String, strFile As String, colFilesFound As Collection)
        
       '*********************************************************
       '* Author: Dragon <sebastian.strand@pp.inet.fi>          *
       '*         http://personal.inet.fi/cool/dragon/vb/       *
       '*                                                       *
       '* Last updated: August 14, 1998                         *
       '*                                                       *
       '* This recursive routine searches for a specified       *
       '* file/files starting from a specified rootfolder       *
       '* You can specify folder and file info with pattern     *
       '* matching (*, ?, # and so on). For more info on        *
       '* pattern matching please refer to the VB documentation *
       '* for the 'Like' function                               *
       '*                                                       *
       '* This function has the following arguments:            *
       '*                                                       *
       '*   strRootFolder  =  the folder from which the search  *
       '*                     starts. The search will only find *
       '*                     files in this directory or it's   *
       '*                     subdirectories                    *
       '*                                                       *
       '*   strFolder = folder information for the files        *
       '*               searched. Specify * to allow files in   *
       '*               any folder. Pattern matching allowed.   *
       '*                                                       *
       '*   strFile = the filename to search for. Pattern       *
       '*             matching allowed.                         *
       '*                                                       *
       '*   colFilesFound = the files found will be placed in   *
       '*                   this collection                     *
       '*                                                       *
       '* Example usage:                                        *
       '* Dim colFiles as New Collection 'Note 'New' keyword!!  *
       '* Call FindFiles("C:\Windows\System","*","doc[123].txt")*
       '*                                                       *
       '* Then colFiles will be filled with all the text files  *
       '* named doc1.txt or doc2.txt or doc3.txt in the Windows\*
       '* System dir and all it's subdirs.                      *
       '*                                                       *
       '*********************************************************
    
        Dim lngSearchHandle As Long
        Dim udtFindData As WIN32_FIND_DATA
        Dim strTemp As String, lngRet As Long
            
        'Check that folder name ends with "\"
        If Right$(strRootFolder, 1) <> "\" Then strRootFolder = strRootFolder & "\"
        
        'Find first file/folder in current folder
        lngSearchHandle = FindFirstFile(strRootFolder & "*", udtFindData)
        
        'Check that we received a valid handle
        If lngSearchHandle = INVALID_HANDLE_VALUE Then Exit Sub
        
        lngRet = 1
        
        Do While lngRet <> 0
            
            'Trim nulls from filename
             strTemp = TrimNulls(udtFindData.cFileName)
            
            If (udtFindData.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY Then
                'It's a dir - make sure it isn't . or .. dirs
                If strTemp <> "." And strTemp <> ".." Then
                    'It's a normal dir: let's dive straight
                    'into it...
                    Call FindFiles(strRootFolder & strTemp, strFolder, strFile, colFilesFound)
                End If
            Else
                'It's a file. First check if the current folder matches
                'the folder path in strFolder
                If (strRootFolder Like strFolder) Then
                    'Folder matches, what about file?
                    If (UCase(strTemp) Like UCase(strFile)) Then
                        'Found one!
                        
                        colFilesFound.Add strRootFolder '& strTemp
                        
                    End If
                End If
            End If
            
            'Get next file/folder
            lngRet = FindNextFile(lngSearchHandle, udtFindData)
            
        Loop
        
        'Close find handle
        Call FindClose(lngSearchHandle)
        
    End Sub
    
    Public Function TrimNulls(strString As String) As String
       
       Dim l As Long
       
       l = InStr(1, strString, Chr(0))
       
       If l = 1 Then
          TrimNulls = ""
       ElseIf l > 0 Then
          TrimNulls = Left$(strString, l - 1)
       Else
          TrimNulls = strString
       End If
       
    End Function

    The following is the code in the form....


    Code:
     Private Sub Command1_Click()
    
      MsgBox "Finding Files of .csv extension in the specified path"
      Dim colFiles As New Collection 'Note 'New' keyword!!  *
      Call FindFiles(Text1.Text, "*", "Cat.csv", colFiles)
        
    End Sub

  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    we can get your email address from your profile, so you don't need to post it with your name. Your email address is in the code remarks, after Author. Remove that!

    code is surrounded by tags, which VBF interprets before posting the thread. CODE turns is on, and /CODE turns it off. To let VBF know that it is a tag, surround the words in []. If I post an example, then VBF thinks its a tag. That's why I used ()'s instead.

  9. #9
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    here is a link to another thread that finds files on a hard drive.
    maybe it will help.

    here

  10. #10
    Banned Verrona's Avatar
    Join Date
    Sep 2004
    Location
    Aylesbury
    Posts
    32
    try reinstalling MSDN, that mite help

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Sep 2004
    Location
    Morgan Town
    Posts
    30
    hi...

    I could figure out the problem...The problem is with the references that are added for the project...I didn't add any new references as I started this project very recently but I tried to add and remove one by one and the problem is with one of the references...

    My code is working now

    Thanks a lott for ur help DAVID...

    have a great weekend..

    byee
    silpa
    Silpa Parnandi
    Masters in Electrical Engg
    West Virginia University

  12. #12
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Resolved

    add the checkmark and [RESOLVED] to your first post to mark the thread as resolved, finally.

    Glad you have it working...

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Sep 2004
    Location
    Morgan Town
    Posts
    30

    Resolved

    The problem is resolved

  14. #14
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    you have to edit the FIRST post of the thread so that it shows up on the main page.

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