📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "修改文件中字符"
ClientHeight = 1980
ClientLeft = 45
ClientTop = 330
ClientWidth = 6285
Icon = "Form1.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 1980
ScaleWidth = 6285
Begin VB.CheckBox Check1
Caption = "搜索时大小写敏感?"
Height = 210
Left = 1065
TabIndex = 3
Top = 1590
Width = 3060
End
Begin VB.TextBox Text3
Height = 270
Left = 1080
TabIndex = 2
Top = 1170
Width = 3390
End
Begin VB.TextBox Text2
Height = 270
Left = 1080
TabIndex = 1
Top = 795
Width = 3390
End
Begin VB.TextBox Text1
Height = 270
Left = 1080
TabIndex = 0
Top = 420
Width = 3390
End
Begin VB.CommandButton Command3
Caption = "关闭退出(&E)"
Height = 345
Left = 4710
TabIndex = 6
Top = 1140
Width = 1425
End
Begin VB.CommandButton Command2
Caption = "开始替换(&R)"
Height = 345
Left = 4710
TabIndex = 5
Top = 772
Width = 1425
End
Begin VB.CommandButton Command1
Caption = "选择(&S) ..."
Height = 345
Left = 4710
TabIndex = 4
Top = 405
Width = 1425
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "替换字串:"
Height = 180
Left = 150
TabIndex = 9
Top = 1215
Width = 810
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "搜索字串:"
Height = 180
Left = 135
TabIndex = 8
Top = 855
Width = 810
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "选择文件:"
Height = 180
Left = 150
TabIndex = 7
Top = 465
Width = 810
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim Ans As String
Ans = GetOpenFileNameDLG("需要修改的文件 *.*|*.*", "请选择一个文件", "", Me.hwnd)
If Ans <> "" Then
Text1.Text = Ans
End If
Text1.SetFocus
End Sub
Private Sub Command2_Click()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "警告! 你是否想修改 " & Trim(Text1.Text) & " 的内容。 "
Msg = Msg & vbCrLf & vbCrLf & " 强力推荐先备份该文件,然后修改?"
Msg = Msg & vbCrLf & vbCrLf & " 你需要继续吗(Y/N)?"
Style = vbYesNo + vbCritical + vbDefaultButton2
Title = "警告!修改文件处于待命状态."
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' User chose Yes.
MyString = "Yes"
Else
MyString = "No"
End If
If MyString = "Yes" Then
'修改Text1.text的文件中Text2.text内容,替换为Text3.text"
ChangeFile Text1.Text, Text2.Text, Text3.Text
End If
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Load()
Label1.Caption = "选择文件:"
Label2.Caption = "搜索字符:"
Label3.Caption = "替换字符:"
Check1.Caption = "搜索时大小写敏感 ?"
Check1.Value = 1
Command1.Caption = "选择(&S) ..."
Command2.Caption = "开始替换(&R)"
Command3.Caption = "关闭退出(&E)"
Command3.Cancel = True
Command2.Enabled = False
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
Private Sub Text1_Change()
If Trim(Text2.Text) = "" Or Trim(Text1.Text) = "" Then
Command2.Enabled = False
Else
Command2.Enabled = True
End If
End Sub
Private Sub Text1_GotFocus()
Text1.SelStart = 0
Text1.SelLength = Len(Trim(Text1.Text))
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.SetFocus
End If
End Sub
Private Sub Text2_Change()
If Trim(Text2.Text) = "" Or Trim(Text1.Text) = "" Then
Command2.Enabled = False
Else
Command2.Enabled = True
End If
End Sub
Private Sub Text2_GotFocus()
Text2.SelStart = 0
Text2.SelLength = Len(Trim(Text2.Text))
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text3.SetFocus
End If
End Sub
Private Sub Text3_GotFocus()
Text3.SelStart = 0
Text3.SelLength = Len(Trim(Text3.Text))
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Command2.Enabled = True Then
Command2.SetFocus
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -