Simple Text Editor
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports System.Configuration
Imports System.Resources
Imports System.Drawing
Imports System.Drawing.Drawing2D
Public Class MainClass
Shared Sub Main()
Dim myform As Form = New TextEditor()
Application.Run(myform)
End Sub
End Class
Public Class TextEditor
Public Property StatusText() As String
Get
Return sspStatus.Text
End Get
Set(ByVal value As String)
sspStatus.Text = value
End Set
End Property
Public Property EditText() As String
Get
Return txtEdit.Text
End Get
Set(ByVal value As String)
txtEdit.Text = value
End Set
End Property
Public Sub ClearEditBox()
EditText = String.Empty
txtEdit.ForeColor = Color.Black
StatusText = "Text box cleared"
End Sub
Private Sub txtEdit_TextChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles txtEdit.TextChanged
'Reset the status bar text
StatusText = "Ready"
End Sub
Private Sub tbrClear_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles tbrClear.Click
ClearEditBox()
End Sub
Public Sub RedText()
txtEdit.ForeColor = Color.Red
StatusText = "The text is red"
End Sub
Private Sub tbrRed_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles tbrRed.Click
RedText()
End Sub
Public Sub BlueText()
txtEdit.ForeColor = Color.Blue
StatusText = "The text is blue"
End Sub
Private Sub tbrBlue_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles tbrBlue.Click
BlueText()
End Sub
Public Sub UppercaseText()
EditText = EditText.ToUpper
StatusText = "The text is all uppercase"
End Sub
Private Sub tbrUpperCase_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles tbrUpperCase.Click
UppercaseText()
End Sub
Public Sub LowercaseText()
EditText = EditText.ToLower
StatusText = "The text is all lowercase"
End Sub
Private Sub tbrLowerCase_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles tbrLowerCase.Click
LowercaseText()
End Sub
Public Sub ShowAboutBox()
End Sub
Private Sub tbrHelpAbout_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles tbrHelpAbout.Click
ShowAboutBox()
End Sub
End Class
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Public Class TextEditor
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
' Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(TextEditor))
Me.ToolStrip1 = New System.Windows.Forms.ToolStrip
Me.tbrClear = New System.Windows.Forms.ToolStripButton
Me.ToolStripSeparator1 = New System.Windows.Forms.ToolStripSeparator
Me.tbrRed = New System.Windows.Forms.ToolStripButton
Me.tbrBlue = New System.Windows.Forms.ToolStripButton
Me.ToolStripSeparator2 = New System.Windows.Forms.ToolStripSeparator
Me.tbrUpperCase = New System.Windows.Forms.ToolStripButton
Me.tbrLowerCase = New System.Windows.Forms.ToolStripButton
Me.ToolStripSeparator3 = New System.Windows.Forms.ToolStripSeparator
Me.tbrHelpAbout = New System.Windows.Forms.ToolStripButton
Me.StatusStrip1 = New System.Windows.Forms.StatusStrip
Me.sspStatus = New System.Windows.Forms.ToolStripStatusLabel
Me.txtEdit = New System.Windows.Forms.TextBox
Me.ToolStrip1.SuspendLayout()
Me.StatusStrip1.SuspendLayout()
Me.SuspendLayout()
'
'ToolStrip1
'
Me.ToolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.tbrClear, Me.ToolStripSeparator1, Me.tbrRed, Me.tbrBlue, Me.ToolStripSeparator2, Me.tbrUpperCase, Me.tbrLowerCase, Me.ToolStripSeparator3, Me.tbrHelpAbout})
Me.ToolStrip1.Location = New System.Drawing.Point(0, 0)
Me.ToolStrip1.Name = "ToolStrip1"
Me.ToolStrip1.Size = New System.Drawing.Size(592, 25)
Me.ToolStrip1.Stretch = True
Me.ToolStrip1.TabIndex = 0
Me.ToolStrip1.Text = "ToolStrip1"
'
'tbrClear
'
Me.tbrClear.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
'Me.tbrClear.Image = CType(resources.GetObject("tbrClear.Image"), System.Drawing.Image)
Me.tbrClear.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None
Me.tbrClear.ImageTransparentColor = System.Drawing.Color.Magenta
Me.tbrClear.Name = "tbrClear"
Me.tbrClear.Text = "New"
Me.tbrClear.ToolTipText = "New"
'
'ToolStripSeparator1
'
Me.ToolStripSeparator1.Name = "ToolStripSeparator1"
'
'tbrRed
'
Me.tbrRed.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
'Me.tbrRed.Image = CType(resources.GetObject("tbrRed.Image"), System.Drawing.Image)
Me.tbrRed.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None
Me.tbrRed.ImageTransparentColor = System.Drawing.Color.Magenta
Me.tbrRed.Name = "tbrRed"
Me.tbrRed.Text = "Red"
Me.tbrRed.ToolTipText = "Red"
'
'tbrBlue
'
Me.tbrBlue.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
'Me.tbrBlue.Image = CType(resources.GetObject("tbrBlue.Image"), System.Drawing.Image)
Me.tbrBlue.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None
Me.tbrBlue.ImageTransparentColor = System.Drawing.Color.Magenta
Me.tbrBlue.Name = "tbrBlue"
Me.tbrBlue.Text = "Blue"
Me.tbrBlue.ToolTipText = "Blue"
'
'ToolStripSeparator2
'
Me.ToolStripSeparator2.Name = "ToolStripSeparator2"
'
'tbrUpperCase
'
Me.tbrUpperCase.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
'Me.tbrUpperCase.Image = CType(resources.GetObject("tbrUpperCase.Image"), System.Drawing.Image)
Me.tbrUpperCase.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None
Me.tbrUpperCase.ImageTransparentColor = System.Drawing.Color.Magenta
Me.tbrUpperCase.Name = "tbrUpperCase"
Me.tbrUpperCase.Text = "Upper Case"
Me.tbrUpperCase.ToolTipText = "Upper Case"
'
'tbrLowerCase
'
Me.tbrLowerCase.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
'Me.tbrLowerCase.Image = CType(resources.GetObject("tbrLowerCase.Image"), System.Drawing.Image)
Me.tbrLowerCase.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None
Me.tbrLowerCase.ImageTransparentColor = System.Drawing.Color.Magenta
Me.tbrLowerCase.Name = "tbrLowerCase"
Me.tbrLowerCase.Text = "Lower Case"
Me.tbrLowerCase.ToolTipText = "Lower Case"
'
'ToolStripSeparator3
'
Me.ToolStripSeparator3.Name = "ToolStripSeparator3"
'
'tbrHelpAbout
'
Me.tbrHelpAbout.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
'Me.tbrHelpAbout.Image = CType(resources.GetObject("tbrHelpAbout.Image"), System.Drawing.Image)
Me.tbrHelpAbout.ImageTransparentColor = System.Drawing.Color.Magenta
Me.tbrHelpAbout.Name = "tbrHelpAbout"
Me.tbrHelpAbout.Text = "About"
Me.tbrHelpAbout.ToolTipText = "About"
'
'StatusStrip1
'
Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.sspStatus})
Me.StatusStrip1.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Table
Me.StatusStrip1.Location = New System.Drawing.Point(0, 411)
Me.StatusStrip1.Name = "StatusStrip1"
Me.StatusStrip1.Size = New System.Drawing.Size(592, 22)
Me.StatusStrip1.TabIndex = 1
Me.StatusStrip1.Text = "StatusStrip1"
'
'sspStatus
'
Me.sspStatus.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
Me.sspStatus.Name = "sspStatus"
Me.sspStatus.Text = "Ready"
'
'txtEdit
'
Me.txtEdit.Dock = System.Windows.Forms.DockStyle.Fill
Me.txtEdit.Location = New System.Drawing.Point(0, 25)
Me.txtEdit.Multiline = True
Me.txtEdit.Name = "txtEdit"
Me.txtEdit.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
Me.txtEdit.Size = New System.Drawing.Size(592, 386)
Me.txtEdit.TabIndex = 2
'
'TextEditor
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(592, 433)
Me.Controls.Add(Me.txtEdit)
Me.Controls.Add(Me.ToolStrip1)
Me.Controls.Add(Me.StatusStrip1)
Me.Name = "TextEditor"
Me.Text = "Text Editor"
Me.ToolStrip1.ResumeLayout(False)
Me.StatusStrip1.ResumeLayout(False)
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents ToolStrip1 As System.Windows.Forms.ToolStrip
Friend WithEvents tbrClear As System.Windows.Forms.ToolStripButton
Friend WithEvents ToolStripSeparator1 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents tbrRed As System.Windows.Forms.ToolStripButton
Friend WithEvents tbrBlue As System.Windows.Forms.ToolStripButton
Friend WithEvents ToolStripSeparator2 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents tbrUpperCase As System.Windows.Forms.ToolStripButton
Friend WithEvents tbrLowerCase As System.Windows.Forms.ToolStripButton
Friend WithEvents ToolStripSeparator3 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents tbrHelpAbout As System.Windows.Forms.ToolStripButton
Friend WithEvents StatusStrip1 As System.Windows.Forms.StatusStrip
Friend WithEvents sspStatus As System.Windows.Forms.ToolStripStatusLabel
Friend WithEvents txtEdit As System.Windows.Forms.TextBox
End Class
Related examples in the same category