One should use Freefile function when dealing with files.
This allows the program to grab the next available number
and anyone reading the code doesn't have to remember what
number was assigned to what file. this is not necessary but
leads to good coding habits and more easily read code, especially when dealing with multiple files.
Code:Private Sub Command1_Click()
Dim intNum as Integer
intNum = Freefile
On Error Resume Next
CommonDialog1.CancelError = True
CommonDialog1.ShowOpen
Open CommonDialog1.Filename For Output As intNum
Print #intNum, "MyText"
Close intNum
End Sub
