O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

FreeFile Function

Class

Microsoft.VisualBasic.FileSystem

Syntax

FreeFile(  )

Return Value

An integer representing the next available file number

Description

Returns the next available file number for use in a FileOpen function

Programming Tips and Gotchas

  • It is good programming practice to always use FreeFile to obtain a file number to use in the FileOpen procedure.

  • You should call FreeFile and store the returned file number to a variable rather than passing the FreeFile function directly as the filenumber argument of the FileOpen procedure. In this way, you save the file handle for a subsequent call to the FileClose procedure.

  • After using the FreeFile function to retrieve a file handle, you should immediately call the FileOpen procedure, particularly if your file access code resides in a multithreaded application or component. Failure to do so may cause the same handle to be assigned to two different variables, so that one of the calls to FileOpen fails.

  • The names of function parameters become the function’s named arguments. Because of this, it is best to use meaningful names for parameters, and to avoid the use of Hungarian notation.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required