Solved

fileexists

Posted on 1998-12-01
6
471 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
  • 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA error replacing data 6 40
using Access 8 75
Search combo error "Data Type Mismatch in Criteria Expression" 2 71
VBA Shell can't Find Word document 11 112
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

828 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