CitectVBA Programming Reference > CitectVBA Function Reference > File I/O Functions > FreeFile


Retrieves the next sequential system file number available for association with a file. Use the FreeFile function to retrieve an unassociated file number from the file system. This number can be used by the Open statement to be associated with a file.



Return Value

Returns an Integer reference number ready for being associated with a file.

Related Functions

Close | FileCopy | Kill | Name | Open


Dim intFileNum as Integer
intFileNum = FreeFile 'retrieve next free file number
Open "c:\TEST.txt" For Output As #intFileNum
Write #intFileNum, "This is a sample line of text."
Close #intFileNum