Lo Que Sea

Páginas: 7 (1750 palabras) Publicado: 3 de marzo de 2013
Proyecto
Formulario MDI

Public Class WordPad

Inherits System.Windows.Forms.Form

Dim ISsaved As Boolean
Dim Fpath As String
Const PNAME = " - WordPad 2010"

Private Sub RT_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RT.TextChanged
ISsaved = False
End Sub

Private Sub save_file()

On Error ResumeNext
With SaveFileDialog1
.AddExtension = True
.InitialDirectory = "C:\"
.Title = ""
.Filter = "Text Documents *.txt|*.txt|Rich Text Format *.rtf|*.rtf|HTML Files *.html|*.html"
End With
If SaveFileDialog1.ShowDialog = DialogResult.OK Then
Select Case SaveFileDialog1.FilterIndex
Case Is =1, 3
RT.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText)
SBAR.Text = " Archivo salvado "
Case Is = 2
RT.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.RichText)
SBAR.Text = " Archivo salvado "
End Select
Fpath = SaveFileDialog1.FileNameMe.Text = Fpath & PNAME
End If
ISsaved = True

End Sub

Private Sub Save()

On Error GoTo 100
Dim M As String
M = Fpath.Substring(Fpath.Length - 3).ToUpper
Select Case M
Case Is = "TXT", "HTM"
RT.SaveFile(Fpath, RichTextBoxStreamType.PlainText)
SBAR.Text = " Archivoguardado "
Case Is = "RTF"
RT.SaveFile(Fpath, RichTextBoxStreamType.RichText)
SBAR.Text = " Archivo guardado "
End Select
ISsaved = True
Exit Sub
100: MsgBox(Err.Description, MsgBoxStyle.OkOnly, Err.Source)
End Sub

Private Sub font_col()
On Error Resume Next
CD.Color = RT.SelectionColorCD.ShowDialog()
RT.SelectionColor = CD.Color
End Sub

Private Sub BtnNuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnNuevo.Click
If Not ISsaved Then
Dim A As Integer
A = MsgBox("Salvar los cambios?", MsgBoxStyle.YesNo, "Salvar")
If A = vbYes Then
If Fpath = PNAME Thensave_file()
RT.Clear()
Me.Text = PNAME
Fpath = PNAME
Else
Save()
RT.Clear()
Me.Text = PNAME
Fpath = PNAME
End If
Else
RT.Clear()
Me.Text = PNAMEFpath = PNAME
End If
End If
End Sub

Private Sub BtnAbrir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAbrir.Click
abrir_text()
End Sub

Private Sub BtnGuardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnGuardar.Click
guardar_text()
End Sub
Private Subguardar_text()
If Fpath = PNAME Then
save_file()
Else
Save()
End If
SBAR.Text = " El archivo ha sido salvado "
ISsaved = True
End Sub

Private Sub BtnImprimir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnImprimir.Click
Imprimir()
End Sub
Private Sub Imprimir()With PP
.Document = PD
.PrinterSettings = PD.PrinterSettings
.AllowSomePages = True
.AllowPrintToFile = True
.AllowSelection = True
.ShowHelp = True
.ShowDialog()
End With
If PP.ShowDialog = DialogResult.OK Then
PD.Print()
End If
End Sub

Private Sub...
Leer documento completo

Regístrate para leer el documento completo.

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS