开发界面
Option Explicit
'SourceTextBox 是上面的源框
'ResultTextBox 是下面的处理预览框
'Form KeyPreview = True
Private Sub Form_Load() '窗口载入时随机选择配色方案
Dim i As Integer
Dim tooltext1 As String
frmMain.Caption = "DelCrLfSpace V0.9 Author: 2022-06-28"
tooltext1 = "包含大量软回车的网络顽固文本,请处理一次后复制至Word文档里,又从Word文档中复制出来再进行处理一次即可"
SourceTextBox.ToolTipText = tooltext1
cmdCopyResult.ToolTipText = tooltext1
Randomize
i = Int((5 * Rnd) + 1)
'MyValue = Int((6 * Rnd) + 1) ' 生成 1 到 6 之间的随机整数值。
Select Case i
Case 1
SourceTextBox.BackColor = vbRed
ResultTextBox.BackColor = vbRed
SourceTextBox.ForeColor = vbYellow
ResultTextBox.ForeColor = vbYellow
Case 2
SourceTextBox.BackColor = vbBlack
ResultTextBox.BackColor = vbBlack
SourceTextBox.ForeColor = vbYellow
ResultTextBox.ForeColor = vbYellow
Case 3
SourceTextBox.BackColor = vbBlue
ResultTextBox.BackColor = vbBlue
SourceTextBox.ForeColor = vbWhite
ResultTextBox.ForeColor = vbWhite
Case 4
SourceTextBox.BackColor = vbGreen
ResultTextBox.BackColor = vbGreen
SourceTextBox.ForeColor = vbBlack
ResultTextBox.ForeColor = vbBlack
Case Else
SourceTextBox.BackColor = vbYellow
ResultTextBox.BackColor = vbYellow
SourceTextBox.ForeColor = vbRed
ResultTextBox.ForeColor = vbRed
End Select
SourceTextBox.Font.Name = "宋体"
ResultTextBox.Font.Name = "宋体"
SourceTextBox.Font.Size = 14
ResultTextBox.Font.Size = 14
SourceTextBox.FontBold = True
ResultTextBox.FontBold = True
End Sub
Public Sub Mysleep() '循环延时函数
Dim i As Integer, s As Integer
i = 1
s = 0
For i = 1 To 100 Step 1
s = i + s
Next i
s = 0
End Sub '2018-12-17添加说明
Private Sub cmdClearMd5TextBox_Click()
' 清空 两个md5文本框 内容
' 清空 结果标签 内容
md5_up_TextBox.Text = ""
md5_lower_TextBox.Text = ""
labCompValue.Caption = ""
End Sub
Private Sub cmdCompareMD5_Click()
' 开始比较两个文本框内的值
Dim i
'如果 "区分大小写"为"否", 就用文本比较模式
If optBuQuFeng.Value = True Then
i = StrComp(md5_up_TextBox.Text, md5_lower_TextBox.Text, vbTextCompare)
End If
' 如果 区分大小写,则用二进制比较模式
If optQuFeng.Value = True Then
i = StrComp(md5_up_TextBox.Text, md5_lower_TextBox.Text, vbBinaryCompare)
End If
If i = 0 Then
labCompValue.Caption = "相同"
Else
labCompValue.Caption = "不同"
End If
End Sub
Private Sub cmdCopyToSourceTextBox_Click()
Dim s As String, s2 As String
s = Clipboard.GetText(vbCFText) ' 取得剪贴板正文
SourceTextBox.Text = s
If s = "" Then '如果是空,就输出空
ResultTextBox.Text = ""
End If
If s <> "" Then '如果不是空,就调用删除空格的函数
s2 = DelSpace(s)
ResultTextBox.Text = s2
End If
'然后把处理好的内容放到剪贴板内
Call Mysleep
Clipboard.SetText ResultTextBox.Text ' 将处理好的内容放置在剪贴板
End Sub
Private Sub cmdClear_Click()
Clipboard.Clear '似乎没用了
End Sub
Private Sub cmdAuto_Click() '是处理命令按钮
Dim s As String, s2 As String
s = SourceTextBox.Text
If s <> "" Then
s2 = DelSpace(s)
ResultTextBox.Text = s2
End If
End Sub
Private Sub cmdCopyResult_Click() '复制结果
Clipboard.Clear ' 清除剪贴板。
Clipboard.SetText ResultTextBox.Text ' 将正文放置在剪贴板上。
End Sub
Private Sub cmdClearUpTextBox_Click()
SourceTextBox.Text = ""
End Sub
Private Sub cmdExit_Click() '退出程序
End
End Sub
Private Sub Form_Activate() '窗口激活处理,窗口第一次打开
Dim s As String, s2 As String
s = Clipboard.GetText(vbCFText) ' 取得剪贴板正文
SourceTextBox.Text = s
If s <> "" Then
s2 = DelSpace(s)
ResultTextBox.Text = s2
End If
If s = "" Then
ResultTextBox.Text = ""
End If
End Sub
Public Function DelSpace(ByRef sD As String) As String '删除换行、空格 功能实现
If sD <> "" Then
sD = Replace(sD, vbCr, "") '回车符
sD = Replace(sD, vbLf, "") '换行符
sD = Replace(sD, vbCrLf, "") '回车换行符
sD = Replace(sD, vbNewLine, "") '新行
sD = Replace(sD, vbTab, "") 'Tab字
sD = Replace(sD, " ", "")
sD = Trim(sD)
End If
DelSpace = sD
End Function '2020-02-07添加说明
'==================不重要功能============================'
Private Sub cmdNotepad_Click() '打开系统记事本功能
Dim notepad As Integer
notepad = Shell("C:\WINDOWS\Notepad.exe", 1)
End Sub
Private Sub cmdPaint_Click() '打开系统画图功能
Dim MsPaint As Integer
MsPaint = Shell("C:\WINDOWS\system32\mspaint.exe", 1)
End Sub
Private Sub cmdCalc_Click() '打开计算器
Dim calc As Integer
calc = Shell("C:\WINDOWS\System32\CALC.EXE", 1) ' 完成Calculator。
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then
Call Unload(Me)
End If
End Sub
Private Sub md5_lower_TextBox_Change()
' 当 "文本1" 和 "文本2" 两个文本框的内容变化时
' 标签实时显示文本框内字符串的长度
' 注意:并没有删除字符串里的空格
lab_Len_upBox.Caption = "文本1长度:" & Len(md5_up_TextBox.Text)
lab_Len_upLowerbox.Caption = "文本2长度:" & Len(md5_lower_TextBox.Text)
End Sub
Private Sub md5_up_TextBox_Change()
' 当 "文本1" 和 "文本2" 两个文本框的内容变化时
' 标签实时显示文本框内字符串的长度
' 注意:并没有删除字符串里的空格
lab_Len_upBox.Caption = "文本1长度:" & Len(md5_up_TextBox.Text)
lab_Len_upLowerbox.Caption = "文本2长度:" & Len(md5_lower_TextBox.Text)
End Sub
Private Sub ResultTextBox_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
End
End If
End Sub
手机扫一扫
移动阅读更方便
你可能感兴趣的文章