User_246

Código Bloco de Notas

Jun 30th, 2021 (edited)
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Componetes do Form
  2. 1 menustrip (guia arquivos - abrir, Salvar, Sair) (guia ferramentas - Fonte, Cor da Fonte, Cor de Fundo, Limpar Tudo)
  3. 1textbox
  4. '==================================================================================================================================
  5. Public Class Form1
  6.     Private Sub AbrirToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AbrirToolStripMenuItem.Click
  7.         Dim ler As String
  8.  
  9.         Dim open As New OpenFileDialog
  10.         open.Title = "Abrir Arquivo de Texto"
  11.         open.Filter = "Arquivo de Texto (*.txt)|*.txt"
  12.         open.FileName = "*.txt"
  13.  
  14.         If open.ShowDialog = DialogResult.OK Then
  15.  
  16.             ler = My.Computer.FileSystem.ReadAllText(open.FileName)
  17.             txt_Text.Text = ler
  18.  
  19.         Else
  20.  
  21.         End If
  22.  
  23.     End Sub
  24.  
  25.     Private Sub SalvarToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SalvarToolStripMenuItem.Click
  26.         Dim save As New SaveFileDialog
  27.         save.Title = "Salvar Arquivo de Texto"
  28.         save.Filter = "ARquivo de Texto (*.txt)|*.txt"
  29.  
  30.  
  31.         If save.ShowDialog = DialogResult.OK Then
  32.  
  33.             Dim file As System.IO.StreamWriter
  34.             file = My.Computer.FileSystem.OpenTextFileWriter(save.FileName, True)
  35.             file.WriteLine(txt_Text.Text)
  36.             file.Close()
  37.         Else
  38.  
  39.  
  40.         End If
  41.  
  42.     End Sub
  43.  
  44.     Private Sub CorDaFonteToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CorDaFonteToolStripMenuItem.Click
  45.         Dim fonte As New FontDialog
  46.         If fonte.ShowDialog = DialogResult.OK Then
  47.             txt_Text.Font = fonte.Font
  48.         End If
  49.     End Sub
  50.  
  51.     Private Sub CorDeFundoToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CorDeFundoToolStripMenuItem.Click
  52.         Dim cor1 As New ColorDialog
  53.         If cor1.ShowDialog = DialogResult.OK Then
  54.             txt_Text.BackColor = cor1.Color
  55.         End If
  56.     End Sub
  57.  
  58.     Private Sub CorDaFonteToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles CorDaFonteToolStripMenuItem1.Click
  59.         Dim cor2 As New ColorDialog
  60.         If cor2.ShowDialog = DialogResult.OK Then
  61.             txt_Text.ForeColor = cor2.Color
  62.         End If
  63.     End Sub
  64.  
  65.     Private Sub LimparTudoToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LimparTudoToolStripMenuItem.Click
  66.         txt_Text.Clear()
  67.     End Sub
  68. End Class
  69.  
Add Comment
Please, Sign In to add comment