-----------------------------------------------------------------------------------代码编辑器重增加代码调节器按钮
Public Editor As Windows.Forms.RichTextBox
Public Sub Test(ByVal sender As Object, ByVal e As EventArgs)
Dim frm As System.Windows.Forms.Form = System.Windows.Forms.Form.ActiveForm
If frm.name = "frmCommand" Then
Editor = ctype(ctype(Ctype(frm.Controls("SplitContainer1"),windows.Forms.SplitContainer).Panel1.controls(0).Controls(0),windows.Forms.SplitContainer).panel1.Controls(0),windows.Forms.SplitContainer).panel1.controls(0)
Else
Editor = Ctype(Ctype(frm.Controls("MyCodeEditor1").Controls(0),Windows.Forms.SplitContainer).Panel1.Controls(0),Windows.Forms.SplitContainer).Panel1.Controls(0)
End If
Select Case sender.Text
Case "调试代码"
With Editor
Dim s As String
For i As Integer = 0 To .Lines.Length - 1
If s Is Nothing Then
s = .Lines(i) & vbcrlf & "MessageBox.Show(" & i + 1 & ")" & vbcrlf
Else
If i < .Lines.Length - 1 Then
s = s & .Lines(i) & vbcrlf & "MessageBox.Show(" & i + 1 & ")" & vbcrlf
Else
s = s & .Lines(i) & vbcrlf & "MessageBox.Show(" & i + 1 & ")"
End If
End If
Next
Editor.Text = s
End With
Case "正式代码"
With Editor
Dim s,s1 As String
Dim q As Integer
For i As Integer = 0 To .Lines.Length - 1 Step 1
q = q + 1
If q Mod 2 = 0 Then
s1 = .Lines(i).TrimStart() '删除字串符前面的空格
If s1.StartsWith("MessageBox.Show(") = False Then '如果开头不是MessageBox.Show 的话
If s Is Nothing Then
s = .Lines(i)
Else
s = s & vbcrlf & .Lines(i)
End If
End If
Else
If s Is Nothing Then
s = .Lines(i)
Else
s = s & vbcrlf & .Lines(i)
End If
End If
Next
Editor.Text = s
End With
Case Else
Return
End Select
End Sub