Results 1 to 5 of 5

Thread: File Exists? with user entry

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    California, USA
    Posts
    111

    Question

    I have a textbox where the user can browse for a file or type the filename in the textbox. If the user types the filename, how do I check to see if that file exists or not?

  2. #2
    Guest
    Code:
    If Dir$("MyFileName") <> "" Then
        'File exists
    Else
        'File does not exist.
    End If

  3. #3
    Guest
    For user input:

    Code:
    Private Sub Command1_Click()
    Dim file As String
    file = InputBox("What file do you want to check?")
    If file <> "" Then
    If Dir$(file) <> "" Then
        'File exists
    Else
        'File does not exist.
    End If
    End If
    End Sub

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Oct 2000
    Location
    California, USA
    Posts
    111

    Question Directory exists?

    How do you check if a directory exists? Thanks.

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    If Dir$(Mydirectory,vbDirectory) <> "" Then 'that directory exists
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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