document.write('<div class="csharp" style="font-family: monospace;"><span style="color: #808080;">\' *********************************************************<br />');
document.write('<br />');
document.write('\'</span><span style="color: #808080;">\'\'</span> FIRST BLOCK<br />');
document.write('Imports <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Collections</span>.<span style="color: #0000FF;">Specialized</span><br />');
document.write('Imports <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Text</span>.<span style="color: #0000FF;">RegularExpressions</span><br />');
document.write('Imports <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Text</span><br />');
document.write('Imports <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Threading</span><br />');
document.write('<br />');
document.write('<span style="color: #0600FF;">Public</span> <span style="color: #FF0000;">Class</span> MainForm<br />');
document.write('<br />');
document.write('&nbsp; &nbsp; <span style="color: #0600FF;">Private</span> _str <span style="color: #0600FF;">As</span> StringCollection<br />');
document.write('&nbsp; &nbsp; <span style="color: #0600FF;">Private</span> _sw <span style="color: #0600FF;">As</span> <a target="_blank"&nbsp; href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">New</span></a> Stopwatch<br />');
document.write('&nbsp; &nbsp; <span style="color: #0600FF;">Private</span> _intRegex <span style="color: #0600FF;">As</span> Regex<br />');
document.write('&nbsp; &nbsp; <span style="color: #0600FF;">Private</span> _floatRegex <span style="color: #0600FF;">As</span> Regex<br />');
document.write('<br />');
document.write('<br />');
document.write('&nbsp; &nbsp; <span style="color: #0600FF;">Private</span> Sub MainForm_Load<span style="color: #000000;">&#40;</span>ByVal sender <span style="color: #0600FF;">As</span> <span style="color: #000000;">System</span>.<span style="color: #FF0000;">Object</span>, ByVal e <span style="color: #0600FF;">As</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">EventArgs</span><span style="color: #000000;">&#41;</span> Handles MyBase.<span style="color: #0000FF;">Load</span><br />');
document.write('&nbsp; &nbsp; &nbsp; &nbsp; WebBrowser1.<span style="color: #0000FF;">DocumentText</span> = <span style="color: #808080;">&quot;This application demonstrates the difference between &lt;b&gt;&lt;code&gt;Parse </span></div><div class="c" style="font-family: monospace;">TryParse</div><div class="c" style="font-family: monospace;"><span style="color: #993333;">Char</span> Arrays</div><div class="c" style="font-family: monospace;">Regex</div><div class="c" style="font-family: monospace;">TryParse</div><div class="c" style="font-family: monospace;">Int32</div><div class="c" style="font-family: monospace;">Decimal</div><div class="c" style="font-family: monospace;">Single</div><div class="c" style="font-family: monospace;"><span style="color: #993333;">Double</span></div>)');
document.write('        If useParse Then parseTime = DoubleParseRoutine()');
document.write('        If useTryParse Then tryParseTime = DoubleTryParseRoutine()');
document.write('        If useCharArray Then');
document.write('            If useOptimizedCharArray Then');
document.write('                charArrayParseTime = OptimizedDoubleCharArrayRoutine()');
document.write('            Else');
document.write('                charArrayParseTime = DoubleCharArrayRoutine()');
document.write('            End If');
document.write('        End If');
document.write('        If useRegex Then regexParseTime = DoubleRegexRoutine()');
document.write('        sb.Append(TimeResult(parseTime, tryParseTime, charArrayParseTime, regexParseTime))');
document.write('');
document.write('        sb.Append("</table>")');
document.write('        WebBrowser1.DocumentText = sb.ToString');
document.write('');
document.write('        Cursor = Cursors.Arrow');
document.write('    End Sub');
document.write('');
document.write('    Private Function TimeResult(ByVal parseTime As Long, ByVal tryParseTime As Long, ByVal charArrayParseTime As Long, ByVal regexParseTime As Long) As String');
document.write('        Return "<td><span style=\'color:red\'>" & parseTime & " ms</span><td>" & tryParseTime & "ms</span><td>" & charArrayParseTime & "ms</span><td>" & regexParseTime & "ms"');
document.write('    End Function');
document.write('');
document.write('    Private Sub CloseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseButton.Click');
document.write('        Me.Close()');
document.write('    End Sub');
document.write('End Class');
document.write('');
document.write('');
document.write('');
document.write('');
document.write('\' ************************************************************');
document.write('\'\'\' SECOND BLOCK');
document.write('<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _');
document.write('Partial Public Class MainForm');
document.write('    Inherits System.Windows.Forms.Form');
document.write('');
document.write('    \'Form overrides dispose to clean up the component list.');
document.write('    <System.Diagnostics.DebuggerNonUserCode()> _');
document.write('    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)');
document.write('        If disposing AndAlso components IsNot Nothing Then');
document.write('            components.Dispose()');
document.write('        End If');
document.write('        MyBase.Dispose(disposing)');
document.write('    End Sub');
document.write('');
document.write('    \'Required by the Windows Form Designer');
document.write('    Private components As System.ComponentModel.IContainer');
document.write('');
document.write('    \'NOTE: The following procedure is required by the Windows Form Designer');
document.write('    \'It can be modified using the Windows Form Designer.  ');
document.write('    \'Do not modify it using the code editor.');
document.write('    <System.Diagnostics.DebuggerStepThrough()> _');
document.write('    Private Sub InitializeComponent()');
document.write('        Me.CloseButton = New System.Windows.Forms.Button');
document.write('        Me.RunButton = New System.Windows.Forms.Button');
document.write('        Me.SuccessRateNumericUpDown = New System.Windows.Forms.NumericUpDown');
document.write('        Me.WebBrowser1 = New System.Windows.Forms.WebBrowser');
document.write('        Me.Label2 = New System.Windows.Forms.Label');
document.write('        Me.Label3 = New System.Windows.Forms.Label');
document.write('        Me.StringCountNumericUpDown = New System.Windows.Forms.NumericUpDown');
document.write('        Me.Label5 = New System.Windows.Forms.Label');
document.write('        Me.Label6 = New System.Windows.Forms.Label');
document.write('        Me.Label1 = New System.Windows.Forms.Label');
document.write('        Me.IntegerRegexTextBox = New System.Windows.Forms.TextBox');
document.write('        Me.Label4 = New System.Windows.Forms.Label');
document.write('        Me.FloatRegexTextBox = New System.Windows.Forms.TextBox');
document.write('        Me.UseTryCheckBox = New System.Windows.Forms.CheckBox');
document.write('        Me.UseTryParseCheckBox = New System.Windows.Forms.CheckBox');
document.write('        Me.UseCharArrayCheckBox = New System.Windows.Forms.CheckBox');
document.write('        Me.UseRegexCheckBox = New System.Windows.Forms.CheckBox');
document.write('        Me.UseOptimizeCharArrayCheckBox = New System.Windows.Forms.CheckBox');
document.write('        CType(Me.SuccessRateNumericUpDown, System.ComponentModel.ISupportInitialize).BeginInit()');
document.write('        CType(Me.StringCountNumericUpDown, System.ComponentModel.ISupportInitialize).BeginInit()');
document.write('        Me.SuspendLayout()');
document.write('        \'');
document.write('        \'CloseButton');
document.write('        \'');
document.write('        Me.CloseButton.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)');
document.write('        Me.CloseButton.DialogResult = System.Windows.Forms.DialogResult.Cancel');
document.write('        Me.CloseButton.Location = New System.Drawing.Point(592, 441)');
document.write('        Me.CloseButton.Margin = New System.Windows.Forms.Padding(4)');
document.write('        Me.CloseButton.Name = "CloseButton"');
document.write('        Me.CloseButton.Size = New System.Drawing.Size(100, 28)');
document.write('        Me.CloseButton.TabIndex = 0');
document.write('        Me.CloseButton.Text = "Close"');
document.write('        \'');
document.write('        \'RunButton');
document.write('        \'');
document.write('        Me.RunButton.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)');
document.write('        Me.RunButton.Location = New System.Drawing.Point(484, 441)');
document.write('        Me.RunButton.Margin = New System.Windows.Forms.Padding(4)');
document.write('        Me.RunButton.Name = "RunButton"');
document.write('        Me.RunButton.Size = New System.Drawing.Size(100, 28)');
document.write('        Me.RunButton.TabIndex = 1');
document.write('        Me.RunButton.Text = "Run"');
document.write('        \'');
document.write('        \'SuccessRateNumericUpDown');
document.write('        \'');
document.write('        Me.SuccessRateNumericUpDown.Location = New System.Drawing.Point(461, 15)');
document.write('        Me.SuccessRateNumericUpDown.Margin = New System.Windows.Forms.Padding(4)');
document.write('        Me.SuccessRateNumericUpDown.Name = "SuccessRateNumericUpDown"');
document.write('        Me.SuccessRateNumericUpDown.Size = New System.Drawing.Size(77, 22)');
document.write('        Me.SuccessRateNumericUpDown.TabIndex = 5');
document.write('        Me.SuccessRateNumericUpDown.Value = New Decimal(New Integer() {100, 0, 0, 0})');
document.write('        \'');
document.write('        \'WebBrowser1');
document.write('        \'');
document.write('        Me.WebBrowser1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _');
document.write('                    Or System.Windows.Forms.AnchorStyles.Left) _');
document.write('                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)');
document.write('        Me.WebBrowser1.Location = New System.Drawing.Point(17, 108)');
document.write('        Me.WebBrowser1.Margin = New System.Windows.Forms.Padding(4)');
document.write('        Me.WebBrowser1.Name = "WebBrowser1"');
document.write('        Me.WebBrowser1.Size = New System.Drawing.Size(675, 325)');
document.write('        \'');
document.write('        \'Label2');
document.write('        \'');
document.write('        Me.Label2.AutoSize = True');
document.write('        Me.Label2.Location = New System.Drawing.Point(547, 17)');
document.write('        Me.Label2.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)');
document.write('        Me.Label2.Name = "Label2"');
document.write('        Me.Label2.Size = New System.Drawing.Size(49, 16)');
document.write('        Me.Label2.TabIndex = 10');
document.write('        Me.Label2.Text = "percent"');
document.write('        \'');
document.write('        \'Label3');
document.write('        \'');
document.write('        Me.Label3.AutoSize = True');
document.write('        Me.Label3.Location = New System.Drawing.Point(16, 17)');
document.write('        Me.Label3.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)');
document.write('        Me.Label3.Name = "Label3"');
document.write('        Me.Label3.Size = New System.Drawing.Size(110, 16)');
document.write('        Me.Label3.TabIndex = 11');
document.write('        Me.Label3.Text = "Attempt to convert"');
document.write('        \'');
document.write('        \'StringCountNumericUpDown');
document.write('        \'');
document.write('        Me.StringCountNumericUpDown.Location = New System.Drawing.Point(144, 15)');
document.write('        Me.StringCountNumericUpDown.Margin = New System.Windows.Forms.Padding(4)');
document.write('        Me.StringCountNumericUpDown.Maximum = New Decimal(New Integer() {999999, 0, 0, 0})');
document.write('        Me.StringCountNumericUpDown.Minimum = New Decimal(New Integer() {1, 0, 0, 0})');
document.write('        Me.StringCountNumericUpDown.Name = "StringCountNumericUpDown"');
document.write('        Me.StringCountNumericUpDown.Size = New System.Drawing.Size(77, 22)');
document.write('        Me.StringCountNumericUpDown.TabIndex = 12');
document.write('        Me.StringCountNumericUpDown.Value = New Decimal(New Integer() {10000, 0, 0, 0})');
document.write('        \'');
document.write('        \'Label5');
document.write('        \'');
document.write('        Me.Label5.AutoSize = True');
document.write('        Me.Label5.Location = New System.Drawing.Point(219, 16)');
document.write('        Me.Label5.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)');
document.write('        Me.Label5.Name = "Label5"');
document.write('        Me.Label5.Size = New System.Drawing.Size(0, 0)');
document.write('        Me.Label5.TabIndex = 13');
document.write('        \'');
document.write('        \'Label6');
document.write('        \'');
document.write('        Me.Label6.AutoSize = True');
document.write('        Me.Label6.Location = New System.Drawing.Point(229, 17)');
document.write('        Me.Label6.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)');
document.write('        Me.Label6.Name = "Label6"');
document.write('        Me.Label6.Size = New System.Drawing.Size(208, 16)');
document.write('        Me.Label6.TabIndex = 14');
document.write('        Me.Label6.Text = "string values with a success rate of"');
document.write('        \'');
document.write('        \'Label1');
document.write('        \'');
document.write('        Me.Label1.AutoSize = True');
document.write('        Me.Label1.Location = New System.Drawing.Point(18, 47)');
document.write('        Me.Label1.Name = "Label1"');
document.write('        Me.Label1.Size = New System.Drawing.Size(88, 16)');
document.write('        Me.Label1.TabIndex = 16');
document.write('        Me.Label1.Text = "Integer Regex"');
document.write('        \'');
document.write('        \'IntegerRegexTextBox');
document.write('        \'');
document.write('        Me.IntegerRegexTextBox.Location = New System.Drawing.Point(112, 44)');
document.write('        Me.IntegerRegexTextBox.Name = "IntegerRegexTextBox"');
document.write('        Me.IntegerRegexTextBox.Size = New System.Drawing.Size(210, 23)');
document.write('        Me.IntegerRegexTextBox.TabIndex = 17');
document.write('        Me.IntegerRegexTextBox.Text = "^([-+]?\d+)$"');
document.write('        \'');
document.write('        \'Label4');
document.write('        \'');
document.write('        Me.Label4.AutoSize = True');
document.write('        Me.Label4.Location = New System.Drawing.Point(397, 47)');
document.write('        Me.Label4.Name = "Label4"');
document.write('        Me.Label4.Size = New System.Drawing.Size(77, 16)');
document.write('        Me.Label4.TabIndex = 18');
document.write('        Me.Label4.Text = "Float Regex"');
document.write('        \'');
document.write('        \'FloatRegexTextBox');
document.write('        \'');
document.write('        Me.FloatRegexTextBox.Location = New System.Drawing.Point(480, 44)');
document.write('        Me.FloatRegexTextBox.Name = "FloatRegexTextBox"');
document.write('        Me.FloatRegexTextBox.Size = New System.Drawing.Size(212, 23)');
document.write('        Me.FloatRegexTextBox.TabIndex = 19');
document.write('        Me.FloatRegexTextBox.Text = "^([-+]?\d+\.?\d*)$"');
document.write('        \'');
document.write('        \'UseTryCheckBox');
document.write('        \'');
document.write('        Me.UseTryCheckBox.AutoSize = True');
document.write('        Me.UseTryCheckBox.Checked = True');
document.write('        Me.UseTryCheckBox.CheckState = System.Windows.Forms.CheckState.Checked');
document.write('        Me.UseTryCheckBox.Location = New System.Drawing.Point(18, 81)');
document.write('        Me.UseTryCheckBox.Name = "UseTryCheckBox"');
document.write('        Me.UseTryCheckBox.Size = New System.Drawing.Size(87, 20)');
document.write('        Me.UseTryCheckBox.TabIndex = 21');
document.write('        Me.UseTryCheckBox.Text = "Use Parse"');
document.write('        \'');
document.write('        \'UseTryParseCheckBox');
document.write('        \'');
document.write('        Me.UseTryParseCheckBox.AutoSize = True');
document.write('        Me.UseTryParseCheckBox.Checked = True');
document.write('        Me.UseTryParseCheckBox.CheckState = System.Windows.Forms.CheckState.Checked');
document.write('        Me.UseTryParseCheckBox.Location = New System.Drawing.Point(109, 81)');
document.write('        Me.UseTryParseCheckBox.Name = "UseTryParseCheckBox"');
document.write('        Me.UseTryParseCheckBox.Size = New System.Drawing.Size(110, 20)');
document.write('        Me.UseTryParseCheckBox.TabIndex = 22');
document.write('        Me.UseTryParseCheckBox.Text = "Use Try Parse"');
document.write('        \'');
document.write('        \'UseCharArrayCheckBox');
document.write('        \'');
document.write('        Me.UseCharArrayCheckBox.AutoSize = True');
document.write('        Me.UseCharArrayCheckBox.Checked = True');
document.write('        Me.UseCharArrayCheckBox.CheckState = System.Windows.Forms.CheckState.Checked');
document.write('        Me.UseCharArrayCheckBox.Location = New System.Drawing.Point(225, 80)');
document.write('        Me.UseCharArrayCheckBox.Name = "UseCharArrayCheckBox"');
document.write('        Me.UseCharArrayCheckBox.Size = New System.Drawing.Size(114, 20)');
document.write('        Me.UseCharArrayCheckBox.TabIndex = 23');
document.write('        Me.UseCharArrayCheckBox.Text = "Use Char Array"');
document.write('        \'');
document.write('        \'UseRegexCheckBox');
document.write('        \'');
document.write('        Me.UseRegexCheckBox.AutoSize = True');
document.write('        Me.UseRegexCheckBox.Checked = True');
document.write('        Me.UseRegexCheckBox.CheckState = System.Windows.Forms.CheckState.Checked');
document.write('        Me.UseRegexCheckBox.Location = New System.Drawing.Point(345, 80)');
document.write('        Me.UseRegexCheckBox.Name = "UseRegexCheckBox"');
document.write('        Me.UseRegexCheckBox.Size = New System.Drawing.Size(91, 20)');
document.write('        Me.UseRegexCheckBox.TabIndex = 24');
document.write('        Me.UseRegexCheckBox.Text = "Use Regex"');
document.write('        \'');
document.write('        \'UseOptimizeCharArrayCheckBox');
document.write('        \'');
document.write('        Me.UseOptimizeCharArrayCheckBox.AccessibleRole = System.Windows.Forms.AccessibleRole.None');
document.write('        Me.UseOptimizeCharArrayCheckBox.AutoSize = True');
document.write('        Me.UseOptimizeCharArrayCheckBox.Location = New System.Drawing.Point(551, 81)');
document.write('        Me.UseOptimizeCharArrayCheckBox.Name = "UseOptimizeCharArrayCheckBox"');
document.write('        Me.UseOptimizeCharArrayCheckBox.RightToLeft = System.Windows.Forms.RightToLeft.Yes');
document.write('        Me.UseOptimizeCharArrayCheckBox.Size = New System.Drawing.Size(141, 20)');
document.write('        Me.UseOptimizeCharArrayCheckBox.TabIndex = 26');
document.write('        Me.UseOptimizeCharArrayCheckBox.Text = "Optimize Char Array"');
document.write('        \'');
document.write('        \'MainForm');
document.write('        \'');
document.write('        Me.AcceptButton = Me.RunButton');
document.write('        Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!)');
document.write('        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font');
document.write('        Me.CancelButton = Me.CloseButton');
document.write('        Me.ClientSize = New System.Drawing.Size(708, 476)');
document.write('        Me.Controls.Add(Me.UseOptimizeCharArrayCheckBox)');
document.write('        Me.Controls.Add(Me.UseRegexCheckBox)');
document.write('        Me.Controls.Add(Me.UseCharArrayCheckBox)');
document.write('        Me.Controls.Add(Me.UseTryParseCheckBox)');
document.write('        Me.Controls.Add(Me.UseTryCheckBox)');
document.write('        Me.Controls.Add(Me.FloatRegexTextBox)');
document.write('        Me.Controls.Add(Me.Label4)');
document.write('        Me.Controls.Add(Me.IntegerRegexTextBox)');
document.write('        Me.Controls.Add(Me.Label1)');
document.write('        Me.Controls.Add(Me.Label6)');
document.write('        Me.Controls.Add(Me.Label5)');
document.write('        Me.Controls.Add(Me.StringCountNumericUpDown)');
document.write('        Me.Controls.Add(Me.Label3)');
document.write('        Me.Controls.Add(Me.Label2)');
document.write('        Me.Controls.Add(Me.WebBrowser1)');
document.write('        Me.Controls.Add(Me.SuccessRateNumericUpDown)');
document.write('        Me.Controls.Add(Me.RunButton)');
document.write('        Me.Controls.Add(Me.CloseButton)');
document.write('        Me.Margin = New System.Windows.Forms.Padding(4)');
document.write('        Me.Name = "MainForm"');
document.write('        Me.Text = "TryParse Benchmark"');
document.write('        CType(Me.SuccessRateNumericUpDown, System.ComponentModel.ISupportInitialize).EndInit()');
document.write('        CType(Me.StringCountNumericUpDown, System.ComponentModel.ISupportInitialize).EndInit()');
document.write('        Me.ResumeLayout(False)');
document.write('        Me.PerformLayout()');
document.write('');
document.write('    End Sub');
document.write('    Friend WithEvents CloseButton As System.Windows.Forms.Button');
document.write('    Friend WithEvents RunButton As System.Windows.Forms.Button');
document.write('    Friend WithEvents SuccessRateNumericUpDown As System.Windows.Forms.NumericUpDown');
document.write('    Friend WithEvents WebBrowser1 As System.Windows.Forms.WebBrowser');
document.write('    Friend WithEvents Label2 As System.Windows.Forms.Label');
document.write('    Friend WithEvents Label3 As System.Windows.Forms.Label');
document.write('    Friend WithEvents StringCountNumericUpDown As System.Windows.Forms.NumericUpDown');
document.write('    Friend WithEvents Label5 As System.Windows.Forms.Label');
document.write('    Friend WithEvents Label6 As System.Windows.Forms.Label');
document.write('    Friend WithEvents Label1 As System.Windows.Forms.Label');
document.write('    Friend WithEvents IntegerRegexTextBox As System.Windows.Forms.TextBox');
document.write('    Friend WithEvents Label4 As System.Windows.Forms.Label');
document.write('    Friend WithEvents FloatRegexTextBox As System.Windows.Forms.TextBox');
document.write('    Friend WithEvents UseTryCheckBox As System.Windows.Forms.CheckBox');
document.write('    Friend WithEvents UseTryParseCheckBox As System.Windows.Forms.CheckBox');
document.write('    Friend WithEvents UseCharArrayCheckBox As System.Windows.Forms.CheckBox');
document.write('    Friend WithEvents UseRegexCheckBox As System.Windows.Forms.CheckBox');
document.write('    Friend WithEvents UseOptimizeCharArrayCheckBox As System.Windows.Forms.CheckBox');
document.write('End Class');
document.write('</code> ');
document.write('<br />&nbsp;<br /><div style="font-size: 12px">Brought to you by the community at <a href="http://www.bytemycode.com/snippets/snippet/54/1/" target="_blank">byteMyCode</a>.</div>');
