Results 1 to 22 of 22

Thread: If Statement (If File Exists)

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2004
    Location
    UK
    Posts
    119

    Resolved If Statement (If File Exists)

    could someone please have a look at this, there seems to be a problem, its not progressing pass the first ELSEIF.

    I'm attempting to create a program that automatically installs DLL's & OCX files into the system32 folder.

    VB Code:
    1. Private Sub Label2_Click()
    2.  
    3.     Dim FileToBeCopied As String
    4.     Dim Location As String
    5.    
    6.     FileToBeCopied = Text1.Text
    7.     Location = "C:\WINDOWS\system32\"
    8.    
    9.     If FileToBeCopied = "" Then
    10.    
    11.         MsgBox "You Need To Select A File To Automatically Install", vbInformation, "No File Selected!"
    12.        
    13.     ElseIf FileExists(Location & FileToBeCopied) Then
    14.    
    15.         MsgBox "The File Has Been Detected As Already Existing", vbExclamation, "The Program Will End"
    16.        
    17.     Else
    18.    
    19.         On Error Resume Next 'Error Proof
    20.         FileCopy FileToBeCopied, Location 'Copy The File FILENAME, PATH
    21.        
    22.     End If
    23.            
    24. End Sub

    & this is what I have in the module for fileexists

    VB Code:
    1. Function FileExists(strFile As String) As Integer
    2.  
    3.     Dim lSize As Long
    4.  
    5.     On Error Resume Next
    6.  
    7.     lSize = -1
    8.  
    9.     lSize = FileLen(strFile)
    10.  
    11.     If lSize = 0 Then
    12.  
    13.         FileExists = 0
    14.  
    15.     ElseIf lSize > 0 Then
    16.  
    17.         FileExists = 1
    18.  
    19.     Else
    20.  
    21.         FileExists = -1
    22.  
    23.     End If
    24.  
    25. End Function

    any idea's...
    Last edited by Shadows; Oct 27th, 2004 at 06:58 AM.

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