Examples: FreeFile function
Dim fileNum As Integer
Dim cdr As String
cdr$ = CurDrive() + "\AUTOEXEC.BAT"
' Assign the lowest available file number to fileNum.
fileNum% = FreeFile()
Print FreeFile() ' Prints 1 (1 is unused)
Open cdr$ For Input Access Read As fileNum%
' Use file number 1
Print FreeFile() ' Prints 2 (1 is in use)
Close fileNum%
Print FreeFile() ' Prints 1 (1 is unused again)