Results 1 to 3 of 3

Thread: require files

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2000
    Location
    plymouth mi usa
    Posts
    1

    Post

    i want visual basic to require some files to be in a dir. what is the code for this.

    also i need code to have vb get some text from a text file like get text after the word ex. here and stop getting it at the word ex. there then take it into another text file and insert the text after the line ex. hope some can help.
    Can someone please help me with this i would appreciate it alot

  2. #2
    Member
    Join Date
    Jan 2000
    Posts
    35

    Post

    Here is a way to check for the existance of a file:
    '
    ' fs - File System Object
    ' f - File / Folder
    '
    Dim fs, f
    '

    '
    Public Function DoesFileExist(Path As String) As Boolean
    Set fs = CreateObject("Scripting.FileSystemObject")
    DoesFileExist = fs.FileExists(Path)
    End Function
    '
    '
    if DoesFileExist(app.path & "\SomeFile.ext")=false then End
    '

  3. #3
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670

    Post

    An easier way to check for the existance of a file;

    Function FileExists(ThisFile As String) As Boolean
    On Error GoTo Doesnt
    Dim fHandle As Integer
    fHandle = FreeFile
    Open ThisFile For Input As #fHandle
    Close #fHandle
    FileExists = True
    Exit Function
    Doesnt:
    FileExists = False
    End Function

    Then use

    If FileExists("the file") Then....

    Else
    ....

    Endif

    ------------------
    Mark "Buzby" Beeton
    VB Developer
    [email protected]



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