Results 1 to 5 of 5

Thread: Entering the file name in a text box if the filename exists

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Posts
    157

    Entering the file name in a text box if the filename exists

    Can anyone tell me the exact code
    line by line
    for entering the file name in a text box
    and file exists
    else msg box "File Not Found"

    if a file name r.txt s entered in text box it should
    display the message it exists else Not Found

    Regds


    Sam F.

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    221
    This will only work in the current directory, will not search all drivers and directories!

    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3. If Not (Len(Dir$(Text1.Text)) <> 0) Then
    4.     MsgBox ("The File Does not exist")
    5. Else
    6.     MsgBox ("The File exists")
    7. End If
    8.  
    9. End Sub

    I hope its what you were looking for

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    221
    I think this makes more sence

    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3. If (Len(Dir$(Text1.Text)) = 0) Then
    4.     MsgBox ("File Not Found")
    5. Else
    6.     MsgBox ("File Found")
    7. End If
    8.  
    9. End Sub

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Posts
    157

    Entering the file name in a text box if the filename exists ERROR

    If (Len(Dir$(Text1.Text)) = 0) Then
    MsgBox ("File Not Found")
    Else
    MsgBox ("File Found")
    End If


    whenever i type a anyting it gives MSGbox File Not Found

    Regds

    Sam F.

  5. #5
    Registered User
    Join Date
    Sep 2002
    Posts
    221

    Re: Entering the file name in a text box if the filename exists ERROR

    Originally posted by samf
    If (Len(Dir$(Text1.Text)) = 0) Then
    MsgBox ("File Not Found")
    Else
    MsgBox ("File Found")
    End If


    whenever i type a anyting it gives MSGbox File Not Found

    Regds

    Sam F.
    This code will only detect the filename you type in the same directory you save this program in.

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