?
Solved

fileexists

Posted on 1998-12-01
6
Medium Priority
?
474 Views
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.
0
Comment
Question by:ralphy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 13

Accepted Solution

by:
Mirkwood earned 600 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
notexist:
    FileExist = False
End Function

0
 

Author Comment

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

Expert Comment

by:Mirkwood
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
0
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!

 

Author Comment

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

Expert Comment

by:Mirkwood
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
0
 

Author Comment

by:ralphy
ID: 1447615
Thanks alot mirkwood, Looks like it'll work fine.
   Ralphy
0

Featured Post

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Suggested Courses

770 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