Posted on 1998-12-01
Last Modified: 2010-05-03
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.
Question by:ralphy
  • 3
  • 3
LVL 13

Accepted Solution

Mirkwood earned 150 total points
ID: 1447610
Private Function FileExist(ByVal fn As String)
    On Error GoTo notexist
    Dim x As VbFileAttribute
    x = GetAttr(fn)
    FileExist = True
    Exit Function
    FileExist = False
End Function


Author Comment

ID: 1447611
I get a user defined type not defined msg, and x as vbfileattribute is highlighted.
LVL 13

Expert Comment

ID: 1447612
Oh, you are using vb4. Try and see if getattr exists. If it does just replace vbFileAttribute with the return type of getattr
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.


Author Comment

ID: 1447613
I still get the user defined type not defined msg for getattr
LVL 13

Expert Comment

ID: 1447614
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

Author Comment

ID: 1447615
Thanks alot mirkwood, Looks like it'll work fine.

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now