Solved

fileexists

Posted on 1998-12-01
6
472 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 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
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
Industry Leaders: 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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
String manipulation in Visual Basic 7 84
VB6 Compile Compatibility Issue 4 123
how can i unlock a picture file that was loaded in a picturebox in visual c#? 4 115
MsgBox 4 71
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

730 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