Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
DIALOGBOX.VB
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form
Private FileName As String
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OpenToolStripMenuItem.Click
Dim openfiledialog1 As New OpenFileDialog
Dim sr As StreamReader
Try
With openfiledialog1
.Filter = "File Text (*.txt)|*.txt|" & "All File|*.*"
If .ShowDialog() = DialogResult.OK Then
FileName = .FileName
sr = New StreamReader(.OpenFile)
Me.Text = sr.ReadToEnd()
End If
End With
Catch es As Exception
MessageBox.Show(es.Message)
Finally
If Not (sr Is Nothing) Then
sr.Close()
End If
End Try
End Sub
Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles SaveToolStripMenuItem.Click
Dim SaveFileDialog1 As New SaveFileDialog
Dim streamw As StreamWriter
Try
With SaveFileDialog1
.FileName = FileName
.Filter = "Text files (*.txt)|*.txt|" & "All files|*.*"
If .ShowDialog() = DialogResult.OK Then
FileName = .FileName
streamw = New StreamWriter(FileName)
streamw.Write(TextBox1.Text)
End If
End With
Catch es As Exception
MessageBox.Show(es.Message)
Finally
If Not (streamw Is Nothing) Then
streamw.Close()
End If
End Try
End Sub
Private Sub SelectFontToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles SelectFontToolStripMenuItem.Click
Dim dlgFontDialog As FontDialog = New FontDialog
OUTPUT
OUTPUT
End Sub
End Class
Output