[Blue]Public[/Blue] [Blue]Class[/Blue] Form6
[Blue]Inherits[/Blue] System.Windows.Forms.Form
#[Blue]Region[/Blue] " Windows Form Designer generated code "
[Blue]Public[/Blue] [Blue]Sub[/Blue] [Blue]New[/Blue]()
[Blue]MyBase[/Blue].[Blue]New[/Blue]()
[Green]'This call is required by the Windows Form Designer.[/Green]
InitializeComponent()
[Green]'Add any initialization after the InitializeComponent() call[/Green]
[Blue]End[/Blue] [Blue]Sub[/Blue]
[Green]'Form overrides dispose to clean up the component list.[/Green]
[Blue]Protected[/Blue] [Blue]Overloads[/Blue] [Blue]Overrides[/Blue] [Blue]Sub[/Blue] Dispose([Blue]ByVal[/Blue] disposing [Blue]As[/Blue] [Blue]Boolean[/Blue])
[Blue]If[/Blue] disposing [Blue]Then[/Blue]
[Blue]If[/Blue] Not (components [Blue]Is[/Blue] [Blue]Nothing[/Blue]) [Blue]Then[/Blue]
components.Dispose()
[Blue]End[/Blue] [Blue]If[/Blue]
[Blue]End[/Blue] [Blue]If[/Blue]
[Blue]MyBase[/Blue].Dispose(disposing)
[Blue]End[/Blue] [Blue]Sub[/Blue]
[Green]'Required by the Windows Form Designer[/Green]
[Blue]Private[/Blue] components [Blue]As[/Blue] System.ComponentModel.IContainer
[Green]'NOTE: The following procedure is required by the Windows Form Designer[/Green]
[Green]'It can be modified using the Windows Form Designer. [/Green]
[Green]'Do not modify it using the code editor.[/Green]
[Blue]Friend[/Blue] WithEvents TextBox1 [Blue]As[/Blue] System.Windows.Forms.TextBox
[Blue]Friend[/Blue] WithEvents TextBox2 [Blue]As[/Blue] System.Windows.Forms.TextBox
[Blue]Friend[/Blue] WithEvents btnLoadTable [Blue]As[/Blue] System.Windows.Forms.Button
[Blue]Friend[/Blue] WithEvents btnInsertCodes [Blue]As[/Blue] System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> [Blue]Private[/Blue] [Blue]Sub[/Blue] InitializeComponent()
[Blue]Me[/Blue].TextBox1 = [Blue]New[/Blue] System.Windows.Forms.TextBox
[Blue]Me[/Blue].TextBox2 = [Blue]New[/Blue] System.Windows.Forms.TextBox
[Blue]Me[/Blue].btnLoadTable = [Blue]New[/Blue] System.Windows.Forms.Button
[Blue]Me[/Blue].btnInsertCodes = [Blue]New[/Blue] System.Windows.Forms.Button
[Blue]Me[/Blue].SuspendLayout()
[Green]'[/Green]
[Green]'TextBox1[/Green]
[Green]'[/Green]
[Blue]Me[/Blue].TextBox1.Location = [Blue]New[/Blue] System.Drawing.Point(16, 16)
[Blue]Me[/Blue].TextBox1.Multiline = [Blue]True[/Blue]
[Blue]Me[/Blue].TextBox1.Name = "TextBox1"
[Blue]Me[/Blue].TextBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
[Blue]Me[/Blue].TextBox1.Size = [Blue]New[/Blue] System.Drawing.Size(552, 216)
[Blue]Me[/Blue].TextBox1.TabIndex = 0
[Blue]Me[/Blue].TextBox1.Text = "TextBox1"
[Green]'[/Green]
[Green]'TextBox2[/Green]
[Green]'[/Green]
[Blue]Me[/Blue].TextBox2.Location = [Blue]New[/Blue] System.Drawing.Point(24, 240)
[Blue]Me[/Blue].TextBox2.Multiline = [Blue]True[/Blue]
[Blue]Me[/Blue].TextBox2.Name = "TextBox2"
[Blue]Me[/Blue].TextBox2.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
[Blue]Me[/Blue].TextBox2.Size = [Blue]New[/Blue] System.Drawing.Size(552, 232)
[Blue]Me[/Blue].TextBox2.TabIndex = 1
[Blue]Me[/Blue].TextBox2.Text = "TextBox2"
[Green]'[/Green]
[Green]'btnLoadTable[/Green]
[Green]'[/Green]
[Blue]Me[/Blue].btnLoadTable.Location = [Blue]New[/Blue] System.Drawing.Point(600, 24)
[Blue]Me[/Blue].btnLoadTable.Name = "btnLoadTable"
[Blue]Me[/Blue].btnLoadTable.Size = [Blue]New[/Blue] System.Drawing.Size(80, 23)
[Blue]Me[/Blue].btnLoadTable.TabIndex = 2
[Blue]Me[/Blue].btnLoadTable.Text = "Load Table"
[Green]'[/Green]
[Green]'btnInsertCodes[/Green]
[Green]'[/Green]
[Blue]Me[/Blue].btnInsertCodes.Location = [Blue]New[/Blue] System.Drawing.Point(600, 72)
[Blue]Me[/Blue].btnInsertCodes.Name = "btnInsertCodes"
[Blue]Me[/Blue].btnInsertCodes.Size = [Blue]New[/Blue] System.Drawing.Size(80, 23)
[Blue]Me[/Blue].btnInsertCodes.TabIndex = 3
[Blue]Me[/Blue].btnInsertCodes.Text = "Insert Codes"
[Green]'[/Green]
[Green]'Form6[/Green]
[Green]'[/Green]
[Blue]Me[/Blue].AutoScaleBaseSize = [Blue]New[/Blue] System.Drawing.Size(5, 13)
[Blue]Me[/Blue].ClientSize = [Blue]New[/Blue] System.Drawing.Size(696, 469)
[Blue]Me[/Blue].Controls.Add([Blue]Me[/Blue].btnInsertCodes)
[Blue]Me[/Blue].Controls.Add([Blue]Me[/Blue].btnLoadTable)
[Blue]Me[/Blue].Controls.Add([Blue]Me[/Blue].TextBox2)
[Blue]Me[/Blue].Controls.Add([Blue]Me[/Blue].TextBox1)
[Blue]Me[/Blue].Name = "Form6"
[Blue]Me[/Blue].Text = "Form6"
[Blue]Me[/Blue].WindowState = System.Windows.Forms.FormWindowState.Maximized
[Blue]Me[/Blue].ResumeLayout([Blue]False[/Blue])
[Blue]End[/Blue] [Blue]Sub[/Blue]
#[Blue]End[/Blue] [Blue]Region[/Blue]
[Blue]Private[/Blue] ht [Blue]As[/Blue] [Blue]New[/Blue] Hashtable
[Blue]Private[/Blue] Lines() [Blue]As[/Blue] [Blue]String[/Blue]
[Blue]Private[/Blue] Words() [Blue]As[/Blue] [Blue]String[/Blue]
[Blue]Private[/Blue] Quote [Blue]As[/Blue] [Blue]String[/Blue] = """"
[Blue]Private[/Blue] Comment [Blue]As[/Blue] [Blue]String[/Blue] = ""
[Blue]Private[/Blue] QuoteActive [Blue]As[/Blue] [Blue]Boolean[/Blue] = [Blue]False[/Blue]
[Blue]Private[/Blue] CommentActive [Blue]As[/Blue] [Blue]Boolean[/Blue] = [Blue]False[/Blue]
[Blue]Private[/Blue] rx [Blue]As[/Blue] [Blue]New[/Blue] System.Text.RegularExpressions.Regex("(\w{1,})|([\(\.\)"" ])|(.)")
[Blue]Private[/Blue] [Blue]Sub[/Blue] btnLoadTable_Click([Blue]ByVal[/Blue] sender [Blue]As[/Blue] System.Object, [Blue]ByVal[/Blue] e [Blue]As[/Blue] System.EventArgs) [Blue]Handles[/Blue] btnLoadTable.Click
[Green]'This list just includes the words in the program so far[/Green]
ht.Clear()
ht.Add("Dim", "Blue")
ht.Add("As", "Blue")
ht.Add("Sub", "Blue")
ht.Add("Function", "Blue")
ht.Add("End", "Blue")
ht.Add("Private", "Blue")
ht.Add("New", "Blue")
ht.Add("While", "Blue")
ht.Add("If", "Blue")
ht.Add("Then", "Blue")
ht.Add("Else", "Blue")
ht.Add("For", "Blue")
ht.Add("Next", "Blue")
ht.Add("To", "Blue")
ht.Add("ByVal", "Blue")
ht.Add("Handles", "Blue")
ht.Add("Return", "Blue")
ht.Add("String", "Blue")
ht.Add("Integer", "Blue")
ht.Add("Boolean", "Blue")
ht.Add("False", "Blue")
ht.Add("True", "Blue")
ht.Add("MyBase", "Blue")
ht.Add("Protected", "Blue")
ht.Add("Overrides", "Blue")
ht.Add("Friend", "Blue")
ht.Add("Overloads", "Blue")
ht.Add("Is", "Blue")
ht.Add("Nothing", "Blue")
ht.Add("Me", "Blue")
ht.Add("Class", "Blue")
ht.Add("Public", "Blue")
ht.Add("Inherits", "Blue")
ht.Add("Region", "Blue")
ht.Add("#Region", "Blue")
ht.Add("#End", "Blue")
ht.Add("Exit", "Blue")
[Blue]End[/Blue] [Blue]Sub[/Blue]
[Blue]Private[/Blue] [Blue]Function[/Blue] GetCodedString([Blue]ByVal[/Blue] w [Blue]As[/Blue] [Blue]String[/Blue], [Blue]ByVal[/Blue] value [Blue]As[/Blue] [Blue]String[/Blue]) [Blue]As[/Blue] [Blue]String[/Blue]
[Green]'#Region and #End Region are special cases so handle it separately[/Green]
[Blue]If[/Blue] w = "#Region" Or w = "#End" [Blue]Then[/Blue]
[Blue]Return[/Blue] "#[" + value + "]" + w.Substring(1) + "[/" + value + "]"
[Blue]Else[/Blue]
[Blue]Return[/Blue] "[" + value + "]" + w + "[/" + value + "]"
[Blue]End[/Blue] [Blue]If[/Blue]
[Blue]End[/Blue] [Blue]Function[/Blue]
[Blue]Private[/Blue] [Blue]Sub[/Blue] btnInsertCodes_Click([Blue]ByVal[/Blue] sender [Blue]As[/Blue] System.Object, [Blue]ByVal[/Blue] e [Blue]As[/Blue] System.EventArgs) [Blue]Handles[/Blue] btnInsertCodes.Click
TextBox2.Text = "[Code]"
[Blue]If[/Blue] TextBox1.Text.Length = 0 [Blue]Then[/Blue] [Blue]Exit[/Blue] [Blue]Sub[/Blue] [Green]'Get out if no text[/Green]
TextBox1.Text = TextBox1.Text.Trim
[Green]'Clean up the string[/Green]
[Blue]Dim[/Blue] s [Blue]As[/Blue] [Blue]String[/Blue] = TextBox1.Text.Replace(vbLf, "")
Lines = s.Split(vbCr.ToCharArray)
[Blue]For[/Blue] a [Blue]As[/Blue] [Blue]Integer[/Blue] = 0 [Blue]To[/Blue] Lines.Length - 1
[Blue]Dim[/Blue] mc [Blue]As[/Blue] System.Text.RegularExpressions.MatchCollection = rx.Matches(Lines(a))
[Blue]For[/Blue] b [Blue]As[/Blue] [Blue]Integer[/Blue] = 0 [Blue]To[/Blue] mc.Count - 1
Select Case mc(b).ToString
Case Quote
QuoteActive = Not QuoteActive
TextBox2.Text += mc(b).ToString
Case Comment
[Blue]If[/Blue] Not QuoteActive [Blue]Then[/Blue]
TextBox2.Text += "[Green]"
TextBox2.Text += mc(b).ToString
CommentActive = [Blue]True[/Blue] [Green]'No need to check, just set it[/Green]
[Blue]End[/Blue] [Blue]If[/Blue]
Case [Blue]Else[/Blue]
[Blue]If[/Blue] QuoteActive [Blue]Then[/Blue]
TextBox2.Text += mc(b).ToString
[Blue]Else[/Blue]
[Blue]If[/Blue] CommentActive [Blue]Then[/Blue]
TextBox2.Text += mc(b).ToString
[Blue]Else[/Blue]
[Blue]If[/Blue] ht.ContainsKey(mc(b).ToString) [Blue]Then[/Blue]
TextBox2.Text += GetCodedString(mc(b).ToString, ht.Item(mc(b).ToString).ToString)
[Blue]Else[/Blue]
TextBox2.Text += mc(b).ToString
[Blue]End[/Blue] [Blue]If[/Blue]
[Blue]End[/Blue] [Blue]If[/Blue]
[Blue]End[/Blue] [Blue]If[/Blue]
[Blue]End[/Blue] Select
[Blue]Next[/Blue]
[Blue]If[/Blue] QuoteActive [Blue]Then[/Blue] QuoteActive = [Blue]False[/Blue]
[Blue]If[/Blue] CommentActive [Blue]Then[/Blue]
CommentActive = [Blue]False[/Blue]
TextBox2.Text += "[ignore][/Green][/ignore]"
[Blue]End[/Blue] [Blue]If[/Blue]
TextBox2.Text += Environment.NewLine
[Blue]Next[/Blue]
TextBox2.Text += "[ignore]