codice:
Dim testo As String
Dim nomefile As String
Dim percorso As String
Private Sub Command1_Click()
'finestra apri - commondialog
CommonDialog1.Flags = cdlOFNHideReadOnly Or cdlOFNExplorer
CommonDialog1.Filter = "File di Testo (*.txt)|*.txt"
CommonDialog1.CancelError = True
CommonDialog1.InitDir = "c:\"
On Error GoTo annulla
CommonDialog1.ShowOpen
nomefile = CommonDialog1.FileName
'legge file
Open nomefile For Input As #1
Input #1, testo
Text1.Text = testo
Close #1
Exit Sub
annulla:
MsgBox (Err.Description)
End Sub

Private Sub Command2_Click()
'finestra salva - commondialog
CommonDialog1.Flags = cdlOFNHideReadOnly Or cdlOFNExplorer
CommonDialog1.Filter = "File di Testo (*.txt)|*.txt"
CommonDialog1.CancelError = True
CommonDialog1.InitDir = "c:\"
On Error GoTo annulla
CommonDialog1.ShowSave
nomefile = CommonDialog1.FileName
' scrive il file su disco
Open nomefile For Output As #1
Print #1, Text1.Text
Close #1
Exit Sub
annulla:
MsgBox (Err.Description)
End Sub

Private Sub Form_Load()
testo = Text1.Text
End Sub