Module Module1
    Sub SaveFile(ByVal context As String)
        '設定所要儲存的檔案類型為文字檔案*.txt
        Form1.SaveFileDialog1.FileName = Form1.DateTimePicker1.Text
        Form1.SaveFileDialog1.Filter = "文字檔案(*.txt)|*.txt"
        '判斷使用者是否在儲存檔案交談窗中按下儲存鈕
        If Form1.SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim filename As String = Form1.SaveFileDialog1.FileName
            '將TextBox1中的內容寫入至檔案中
            My.Computer.FileSystem.WriteAllText(filename, context, False)
        End If
    End Sub
    Sub OpenFile()
        '設定所要開啟的檔案類型為文字檔案*.txt
        Form1.OpenFileDialog1.Filter = "文字檔案(*.txt)|*.txt"
        '判斷使用者是否在開啟舊檔交談窗中按下開啟鈕
        If Form1.OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim filename As String = Form1.OpenFileDialog1.FileName
            '讀取檔案並將讀取到的內容設定給TextBox1
            Form1.TextBox1.Text = My.Computer.FileSystem.ReadAllText(filename)
        End If
    End Sub
End Module
