Modeless Dialog
Imports System
Imports System.Drawing
Imports System.Reflection
Imports System.Windows.Forms
Imports System.IO
public class MainClass
Shared Sub Main()
Dim form1 As Form = New MainForm
Application.Run(form1)
End Sub
End Class
Public Class AuxForm
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
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.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents FindBox As System.Windows.Forms.TextBox
Friend WithEvents ReplaceBox As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.FindBox = New System.Windows.Forms.TextBox()
Me.Button1 = New System.Windows.Forms.Button()
Me.ReplaceBox = New System.Windows.Forms.TextBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.Button2 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'FindBox
'
Me.FindBox.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.FindBox.Location = New System.Drawing.Point(4, 24)
Me.FindBox.Name = "FindBox"
Me.FindBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
Me.FindBox.Size = New System.Drawing.Size(256, 22)
Me.FindBox.TabIndex = 0
Me.FindBox.Text = ""
'
'Button1
'
Me.Button1.Font = New System.Drawing.Font("Verdana", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button1.Location = New System.Drawing.Point(6, 94)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(101, 33)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Replace"
'
'ReplaceBox
'
Me.ReplaceBox.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ReplaceBox.Location = New System.Drawing.Point(4, 67)
Me.ReplaceBox.Name = "ReplaceBox"
Me.ReplaceBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
Me.ReplaceBox.Size = New System.Drawing.Size(256, 22)
Me.ReplaceBox.TabIndex = 2
Me.ReplaceBox.Text = ""
'
'Label1
'
Me.Label1.Font = New System.Drawing.Font("Verdana", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(6, 5)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(100, 15)
Me.Label1.TabIndex = 3
Me.Label1.Text = "Find Text"
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("Verdana", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label2.Location = New System.Drawing.Point(4, 47)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(100, 17)
Me.Label2.TabIndex = 4
Me.Label2.Text = "Replace with"
'
'Button2
'
Me.Button2.Font = New System.Drawing.Font("Verdana", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button2.Location = New System.Drawing.Point(155, 96)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(101, 33)
Me.Button2.TabIndex = 5
Me.Button2.Text = "Close"
'
'AuxForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(262, 133)
Me.ControlBox = False
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button2, Me.Label2, Me.Label1, Me.ReplaceBox, Me.Button1, Me.FindBox})
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "AuxForm"
Me.Text = "Auxiliary Form"
Me.TopMost = True
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MainForm.txt.Text = MainForm.txt.Text.Replace(FindBox.Text, ReplaceBox.Text)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class
Public Class MainForm
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
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.
Friend WithEvents bttnFind As System.Windows.Forms.Button
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.bttnFind = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Font = New System.Drawing.Font("Verdana", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TextBox1.Location = New System.Drawing.Point(6, 8)
Me.TextBox1.Multiline = True
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
Me.TextBox1.Size = New System.Drawing.Size(576, 278)
Me.TextBox1.TabIndex = 0
Me.TextBox1.Text = ""
'
'bttnFind
'
Me.bttnFind.Font = New System.Drawing.Font("Verdana", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.bttnFind.Location = New System.Drawing.Point(398, 294)
Me.bttnFind.Name = "bttnFind"
Me.bttnFind.Size = New System.Drawing.Size(185, 33)
Me.bttnFind.TabIndex = 1
Me.bttnFind.Text = "Find && Replace"
'
'MainForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(588, 333)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.bttnFind, Me.TextBox1})
Me.Name = "MainForm"
Me.Text = "Main Form"
Me.ResumeLayout(False)
End Sub
#End Region
Public Shared txt As TextBox
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnFind.Click
Dim aForm As New AuxForm()
aForm.FindBox.Text = TextBox1.SelectedText
aForm.Show()
End Sub
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txt = TextBox1
End Sub
End Class
Related examples in the same category