return value from a fucntion

P

pabs

I'm using the following function to verify the existance of a file

Private Function FileExists(fname) As Boolean
' Returns TRUE if the file exists
Dim x As String
x = Dir(fname)
If x <> "" Then FileExists = True _
Else FileExists = False
End Function

I call FileExists(filename) from another routine and I need to know th
result from that check.

how can I check the return from that fucntion (either false or True) ?

thanks

Pab
 
B

Bob Phillips

Pabs,

Something like

If FileExists("C:\myFile.xls") = TRUE Then
' do your thing
Else
' do something els
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
B

Beto

pabs said:
I'm using the following function to verify the existance of a file

Private Function FileExists(fname) As Boolean
' Returns TRUE if the file exists
Dim x As String
x = Dir(fname)
If x <> "" Then FileExists = True _
Else FileExists = False
End Function

I call FileExists(filename) from another routine and I need to know the
result from that check.

how can I check the return from that fucntion (either false or True) ?

Assign it to a variable like:

Answer = FileExists(Filename)

or use it directly:

If FileExists(Filename) Then
' Code if the file exists.
End If

Regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top