Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 476
  • Last Modified:

fileexists

In vb4 I'm trying to have a button either setup a program(if it is not on the computer) or shell to the program if it is already there. I would like to use an If....Else but I can't figure out how to use the fileexists wording.
0
ralphy
Asked:
ralphy
  • 3
  • 3
1 Solution
 
MirkwoodCommented:
Private Function FileExist(ByVal fn As String)
    On Error GoTo notexist
    Dim x As VbFileAttribute
    x = GetAttr(fn)
    FileExist = True
    Exit Function
notexist:
    FileExist = False
End Function

0
 
ralphyAuthor Commented:
I get a user defined type not defined msg, and x as vbfileattribute is highlighted.
0
 
MirkwoodCommented:
Oh, you are using vb4. Try and see if getattr exists. If it does just replace vbFileAttribute with the return type of getattr
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
ralphyAuthor Commented:
I still get the user defined type not defined msg for getattr
0
 
MirkwoodCommented:
Public Function fileExist(fileName As String) As Boolean
    Dim l As Long
   
    On Error Resume Next
   
    l = FileLen(fileName)
   
    fileExist = Not (Err.Number > 0)
   
    On Error GoTo 0
End Function
0
 
ralphyAuthor Commented:
Thanks alot mirkwood, Looks like it'll work fine.
   Ralphy
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now