jueves, 25 de agosto de 2016
NEGRITA, CURSIVA, SUBRAYADO Y DOBLE SUBRAYADO.
agosto 25, 2016
No comments
Sub cambiarestilo(ByVal estiloselec As FontStyle)
Dim estilo As FontStyle = RichTextBox1.SelectionFont.Style
If estiloselec = FontStyle.Bold Then
If RichTextBox1.SelectionFont.Bold = False Then
estilo += FontStyle.Bold
Else
estilo -= FontStyle.Bold
End If
ElseIf estiloselec = FontStyle.Italic Then
If RichTextBox1.SelectionFont.Italic = False Then
estilo += FontStyle.Italic
Else
estilo -= FontStyle.Italic
End If
ElseIf estiloselec = FontStyle.Underline Then
If RichTextBox1.SelectionFont.Underline = False Then
estilo += FontStyle.Underline
Else
estilo -= FontStyle.Underline
End If
ElseIf estiloselec = FontStyle.Strikeout Then
If RichTextBox1.SelectionFont.Strikeout = False Then
estilo += FontStyle.Strikeout
Else
estilo -= FontStyle.Strikeout
End If
End If
RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, estilo)
End Sub
--------------------------------------
En cada Botón
cambiarestilo(FontStyle.Bold)
cambiarestilo(FontStyle.Italic)
cambiarestilo(FontStyle.Underline)
cambiarestilo(FontStyle.Strikeout)
Dim estilo As FontStyle = RichTextBox1.SelectionFont.Style
If estiloselec = FontStyle.Bold Then
If RichTextBox1.SelectionFont.Bold = False Then
estilo += FontStyle.Bold
Else
estilo -= FontStyle.Bold
End If
ElseIf estiloselec = FontStyle.Italic Then
If RichTextBox1.SelectionFont.Italic = False Then
estilo += FontStyle.Italic
Else
estilo -= FontStyle.Italic
End If
ElseIf estiloselec = FontStyle.Underline Then
If RichTextBox1.SelectionFont.Underline = False Then
estilo += FontStyle.Underline
Else
estilo -= FontStyle.Underline
End If
ElseIf estiloselec = FontStyle.Strikeout Then
If RichTextBox1.SelectionFont.Strikeout = False Then
estilo += FontStyle.Strikeout
Else
estilo -= FontStyle.Strikeout
End If
End If
RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, estilo)
End Sub
--------------------------------------
En cada Botón
cambiarestilo(FontStyle.Bold)
cambiarestilo(FontStyle.Italic)
cambiarestilo(FontStyle.Underline)
cambiarestilo(FontStyle.Strikeout)
miércoles, 24 de agosto de 2016
lunes, 22 de agosto de 2016
CODIFICACIÓN DE COMBOBOX FUENTE
agosto 22, 2016
No comments
Imports System.Drawing.Text
Imports System.IO
Public Class Form1
Private Sub CarregarFont()
If My.Computer.FileSystem.FileExists(Application.StartupPath & "\font.txt") = False Then
Dim fi As New System.IO.StreamWriter(Application.StartupPath & "\font.txt")
Dim family As FontFamily
For Each family In FontFamily.Families
If family.IsStyleAvailable(FontStyle.Bold) = False Then Exit For
fi.WriteLine(family.Name)
Next family
fi.Close()
End If
'-------------------------------------------------------------------------------------------/
Dim linha As New StreamReader(Application.StartupPath & "\font.txt")
Do While Not linha.EndOfStream
txtFont.Items.Add(linha.ReadLine)
Loop
linha.Close()
End Sub
Private Sub txtSize_ValueChanged(ByVal sender As Object, ByVal e As EventArgs) Handles txtSize.ValueChanged
Dim f As New Font(RichTextBox1.SelectionFont.FontFamily, txtSize.Value)
RichTextBox1.SelectionFont = f
End Sub
Private Sub txtFont_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles txtFont.SelectedIndexChanged
Dim f As New Font(txtFont.Text, RichTextBox1.SelectionFont.Size)
RichTextBox1.SelectionFont = f
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
CarregarFont()
End Sub
End Class
lunes, 15 de agosto de 2016
CODIGO DEL EDITOR DE TEXTOS
agosto 15, 2016
No comments
Les dejo aqui los codigos:
Abrir:
Dim Open As New OpenFileDialog()
Dim myStreamReader As System.IO.StreamReader
Open.Filter = "Text [*.txt*]|*.txt|All Files [*,*]|*,*"
Open.CheckFileExists = True
Open.Title = "Abrir Archivo"
Open.ShowDialog(Me)
Try
Open.OpenFile()
myStreamReader = System.IO.File.OpenText(Open.FileName)
document.Text = myStreamReader.ReadToEnd()
Catch ex As Exception
End Try
Guardar:
Dim Save As New SaveFileDialog()
Dim myStreamWriter As System.IO.StreamWriter
Save.Filter = "Text (*.txt)|*.txt|HTML(*.html*)|*.html|PHP(*.php*)|*.php*|All files(*.*)|*.*"
Save.CheckPathExists = True
Save.Title = "Guardar como"
Save.ShowDialog(Me)
Try
myStreamWriter = System.IO.File.AppendText(Save.FileName)
myStreamWriter.Write(document.text)
myStreamWriter.Flush()
Catch ex As Exception
End Try
Copiar: document.copy()
Cortar: document.Cut()
Pegar: document.Paste()
Undo: document.Undo()
Redo: document.Redo()
Fuente:
Try Dim dlg As FontDialog = New FontDialog dlg.Font = document.font If dlg.showdialog = System.Windows.Forms.DialogResult.OK Then document.Font = dlg.Font End If
Catch ex As Exception: End Try
Color:
Try Dim dlg As ColorDialog = New ColorDialog dlg.Color = document.Forecolor If dlg.ShowDialog = System.Windows.Forms.DialogResult.Ok Then document.Forecolor = dlg.Color End If
Catch ex As Exception
End Try
Abrir:
Dim Open As New OpenFileDialog()
Dim myStreamReader As System.IO.StreamReader
Open.Filter = "Text [*.txt*]|*.txt|All Files [*,*]|*,*"
Open.CheckFileExists = True
Open.Title = "Abrir Archivo"
Open.ShowDialog(Me)
Try
Open.OpenFile()
myStreamReader = System.IO.File.OpenText(Open.FileName)
document.Text = myStreamReader.ReadToEnd()
Catch ex As Exception
End Try
Guardar:
Dim Save As New SaveFileDialog()
Dim myStreamWriter As System.IO.StreamWriter
Save.Filter = "Text (*.txt)|*.txt|HTML(*.html*)|*.html|PHP(*.php*)|*.php*|All files(*.*)|*.*"
Save.CheckPathExists = True
Save.Title = "Guardar como"
Save.ShowDialog(Me)
Try
myStreamWriter = System.IO.File.AppendText(Save.FileName)
myStreamWriter.Write(document.text)
myStreamWriter.Flush()
Catch ex As Exception
End Try
Copiar: document.copy()
Cortar: document.Cut()
Pegar: document.Paste()
Undo: document.Undo()
Redo: document.Redo()
Fuente:
Try Dim dlg As FontDialog = New FontDialog dlg.Font = document.font If dlg.showdialog = System.Windows.Forms.DialogResult.OK Then document.Font = dlg.Font End If
Catch ex As Exception: End Try
Color:
Try Dim dlg As ColorDialog = New ColorDialog dlg.Color = document.Forecolor If dlg.ShowDialog = System.Windows.Forms.DialogResult.Ok Then document.Forecolor = dlg.Color End If
Catch ex As Exception
End Try
Otro código
Los codigos son:
Nuevo:
document.Clear
Abrir:
Dim open As New OpenFileDialog Dim myStreamReader As System.IO.StreamReader open.Filter = "Text[*.txt*]|*.txt|All Files [*.*]|*.*" open.CheckFileExists = True open.Title = "Abrir Archivo" open.ShowDialog(Me) Try open.OpenFile() myStreamReader = System.IO.File.OpenText(open.FileName) document.Text = myStreamReader.ReadToEnd Catch ex As Exception End Try
Guardar Como:
Dim save As New SaveFileDialog Dim myStreamWriter As System.IO.StreamWriter save.Filter = "Text (*.txt)|*.txt|HTML(*.html*)|*.html|PHP(*.php*)|*.php*|All Files(*.*)|*.*" save.CheckPathExists = True save.Title = "Guardar Como" save.ShowDialog(Me) Try myStreamWriter = System.IO.File.AppendText(save.FileName) myStreamWriter.Write(document.Text) myStreamWriter.Flush() Catch ex As Exception End Try
Salir:
End
Deshacer:
document.Undo
Rehacer:
document.Redo
Copiar:
document.Copy
Pegar:
document.Paste
Cortar:
document.Cut
Seleccionar Todo:
document.SelectAll
Limpiar Texto:
document.Clear
Fuente:
Try Dim dlg As FontDialog = New FontDialog dlg.Font = document.Font If dlg.ShowDialog = System.Windows.Forms.DialogResult.OK Then document.Font = dlg.Font End If Catch ex As Exception End Try
Color de Fuente:
Try Dim dlg As ColorDialog = New ColorDialog dlg.Color = document.ForeColor If dlg.ShowDialog = System.Windows.Forms.DialogResult.OK Then document.ForeColor = dlg.Color End If Catch ex As Exception End Try
Color de Fondo:
Try Dim dlg As ColorDialog = New ColorDialog dlg.Color = document.BackColor If dlg.ShowDialog = System.Windows.Forms.DialogResult.OK Then document.BackColor = dlg.Color End If Catch ex As Exception End Try
Nuevo:
document.Clear
Abrir:
Dim open As New OpenFileDialog Dim myStreamReader As System.IO.StreamReader open.Filter = "Text[*.txt*]|*.txt|All Files [*.*]|*.*" open.CheckFileExists = True open.Title = "Abrir Archivo" open.ShowDialog(Me) Try open.OpenFile() myStreamReader = System.IO.File.OpenText(open.FileName) document.Text = myStreamReader.ReadToEnd Catch ex As Exception End Try
Guardar Como:
Dim save As New SaveFileDialog Dim myStreamWriter As System.IO.StreamWriter save.Filter = "Text (*.txt)|*.txt|HTML(*.html*)|*.html|PHP(*.php*)|*.php*|All Files(*.*)|*.*" save.CheckPathExists = True save.Title = "Guardar Como" save.ShowDialog(Me) Try myStreamWriter = System.IO.File.AppendText(save.FileName) myStreamWriter.Write(document.Text) myStreamWriter.Flush() Catch ex As Exception End Try
Salir:
End
Deshacer:
document.Undo
Rehacer:
document.Redo
Copiar:
document.Copy
Pegar:
document.Paste
Cortar:
document.Cut
Seleccionar Todo:
document.SelectAll
Limpiar Texto:
document.Clear
Fuente:
Try Dim dlg As FontDialog = New FontDialog dlg.Font = document.Font If dlg.ShowDialog = System.Windows.Forms.DialogResult.OK Then document.Font = dlg.Font End If Catch ex As Exception End Try
Color de Fuente:
Try Dim dlg As ColorDialog = New ColorDialog dlg.Color = document.ForeColor If dlg.ShowDialog = System.Windows.Forms.DialogResult.OK Then document.ForeColor = dlg.Color End If Catch ex As Exception End Try
Color de Fondo:
Try Dim dlg As ColorDialog = New ColorDialog dlg.Color = document.BackColor If dlg.ShowDialog = System.Windows.Forms.DialogResult.OK Then document.BackColor = dlg.Color End If Catch ex As Exception End Try