📄 form1.vb
字号:
Public Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents ComboBox2 As System.Windows.Forms.ComboBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'此调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写释放,以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
MyBase.Dispose(disposing)
End Sub
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改它。
'不要使用代码编辑器修改它。
Private Sub InitializeComponent()
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.ComboBox2 = New System.Windows.Forms.ComboBox
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
Me.Label4 = New System.Windows.Forms.Label
'
'ComboBox1
'
Me.ComboBox1.DisplayMember = "0"
Me.ComboBox1.Items.Add("*.bak")
Me.ComboBox1.Items.Add("*.cef")
Me.ComboBox1.Items.Add("*.knw")
Me.ComboBox1.Items.Add("*.txt")
Me.ComboBox1.Items.Add("*.dx")
Me.ComboBox1.Items.Add("其它")
Me.ComboBox1.Location = New System.Drawing.Point(51, 46)
Me.ComboBox1.Size = New System.Drawing.Size(69, 22)
Me.ComboBox1.ValueMember = "0"
'
'ComboBox2
'
Me.ComboBox2.DisplayMember = "0"
Me.ComboBox2.Items.Add("*.bak")
Me.ComboBox2.Items.Add("*.cef")
Me.ComboBox2.Items.Add("*.knw")
Me.ComboBox2.Items.Add("*.txt")
Me.ComboBox2.Items.Add("*.dx")
Me.ComboBox2.Items.Add("其它")
Me.ComboBox2.Location = New System.Drawing.Point(149, 46)
Me.ComboBox2.Size = New System.Drawing.Size(68, 22)
Me.ComboBox2.ValueMember = "1"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(126, 46)
Me.Label1.Size = New System.Drawing.Size(17, 22)
Me.Label1.Text = "到"
'
'Label2
'
Me.Label2.Font = New System.Drawing.Font("Tahoma", 20.0!, System.Drawing.FontStyle.Regular)
Me.Label2.Location = New System.Drawing.Point(16, 9)
Me.Label2.Size = New System.Drawing.Size(221, 34)
Me.Label2.Text = "更改文件后缀名"
'
'Label3
'
Me.Label3.Location = New System.Drawing.Point(25, 46)
Me.Label3.Size = New System.Drawing.Size(20, 22)
Me.Label3.Text = "由"
'
'Button1
'
Me.Button1.BackColor = System.Drawing.Color.Olive
Me.Button1.ForeColor = System.Drawing.Color.Yellow
Me.Button1.Location = New System.Drawing.Point(89, 234)
Me.Button1.Size = New System.Drawing.Size(72, 20)
Me.Button1.Text = "执行"
'
'OpenFileDialog1
'
Me.OpenFileDialog1.FileName = "OpenFileDialog1"
'
'Label4
'
Me.Label4.Location = New System.Drawing.Point(24, 84)
Me.Label4.Size = New System.Drawing.Size(192, 126)
'
'Form1
'
Me.ClientSize = New System.Drawing.Size(240, 268)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.ComboBox2)
Me.Controls.Add(Me.ComboBox1)
Me.Menu = Me.MainMenu1
Me.MinimizeBox = False
Me.Text = "ReName"
End Sub
Public Shared Sub FileCopy(ByVal Source As String, ByVal Destination As String)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Me.ComboBox1.SelectedItem = Me.ComboBox2.SelectedItem Then
MsgBox("更改前、后后缀名相同,请重新选择。")
Else
Dim a As String
Dim b As String
a = "改前文件 (" & Me.ComboBox1.SelectedItem & ")|" & Me.ComboBox1.SelectedItem & """"
OpenFileDialog1.Filter = a
OpenFileDialog1.ShowDialog()
On Error GoTo ErrHandler
Me.Label4.Text = OpenFileDialog1.FileName
Dim Source As String
Dim Destination As String
Source = OpenFileDialog1.FileName
a = Me.ComboBox1.SelectedItem
a = Replace(a, "*", "", 1, -1, CompareMethod.Binary)
b = Me.ComboBox2.SelectedItem
b = "replace" & Replace(b, "*", "", 1, -1, CompareMethod.Binary)
Destination = Replace(OpenFileDialog1.FileName, a, b, 1, -1, CompareMethod.Binary)
System.IO.File.Copy(Source, Destination)
Me.Label4.Text = Me.Label4.Text + Chr(13) + Chr(10) + "已改为" + Chr(13) + Chr(10) + Destination
MsgBox("ok")
End If
ErrHandler:
Exit Sub '点击了取消
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim a As String
If Me.ComboBox1.SelectedItem = "其它" Then
a = "" : a = InputBox(a, "改前后缀名", "*.", -1, -1)
Me.ComboBox1.Items.Add(a)
Me.ComboBox1.SelectedItem = a
End If
End Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
Dim a As String
If Me.ComboBox2.SelectedItem = "其它" Then
a = "" : a = InputBox(a, "改后后缀名", "*.", -1, -1)
Me.ComboBox2.Items.Add(a)
Me.ComboBox2.SelectedItem = a
End If
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -