[AccessD] Need help with return in a function

Jim Dettman jimdettman at verizon.net
Thu Apr 28 16:50:00 CDT 2016


 Just to add in one comment, "Return" is a valid VBA statement, but in VBA
it's used in conjunction with a Gosub within a procedure.

 Return <value> 

 in more modern languages does return a value from a procedure.  So VBA is a
little confusing in this regard (it's a throwback to the original Dartmouth
Basic).

Jim.

-----Original Message-----
From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
Kaup, Chester
Sent: Thursday, April 28, 2016 01:56 PM
To: Access Developers discussion and problem solving
Subject: [AccessD] Need help with return in a function

Came across a bit of code in a database and I don't understand what one line
is supposed to do or how it is intended to work. I get a syntax error of
"Expected end of statement"  The line in question is return Len(Dir$(aFile))
>0. Thanks for the assistance.

Here is the whole function

Function Delete_File(aFile)
    Dim B As String
    On Error Resume
    Kill aFile
    On Error GoTo 0
    return Len(Dir$(aFile)) > 0         ' Make sure it actually got deleted.
End Function
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list