?? form1.vb
字號:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim strInput, Code, Record, c As String
Dim i%, length%, iAsc%
#Region " Windows 窗體設計器生成的代碼 "
Public Sub New()
MyBase.New()
'該調用是 Windows 窗體設計器所必需的。
InitializeComponent()
'在 InitializeComponent() 調用之后添加任何初始化
End Sub
'窗體重寫處置以清理組件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗體設計器所必需的
Private components As System.ComponentModel.IContainer
'注意:以下過程是 Windows 窗體設計器所必需的
'可以使用 Windows 窗體設計器修改此過程。
'不要使用代碼編輯器修改它。
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Button3 As System.Windows.Forms.Button
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label()
Me.Button1 = New System.Windows.Forms.Button()
Me.Button2 = New System.Windows.Forms.Button()
Me.Button3 = New System.Windows.Forms.Button()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.TextBox2 = New System.Windows.Forms.TextBox()
Me.TextBox3 = New System.Windows.Forms.TextBox()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(0, 8)
Me.Label1.Name = "Label1"
Me.Label1.TabIndex = 0
Me.Label1.Text = "輸入字符串"
'
'Button1
'
Me.Button1.Font = New System.Drawing.Font("宋體", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Button1.Location = New System.Drawing.Point(8, 32)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(48, 23)
Me.Button1.TabIndex = 1
Me.Button1.Text = "加密"
'
'Button2
'
Me.Button2.Font = New System.Drawing.Font("宋體", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Button2.Location = New System.Drawing.Point(8, 64)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(48, 23)
Me.Button2.TabIndex = 2
Me.Button2.Text = "解密"
'
'Button3
'
Me.Button3.Font = New System.Drawing.Font("宋體", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.Button3.Location = New System.Drawing.Point(8, 96)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing.Size(48, 23)
Me.Button3.TabIndex = 3
Me.Button3.Text = "清屏"
'
'TextBox1
'
Me.TextBox1.Font = New System.Drawing.Font("宋體", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.TextBox1.Location = New System.Drawing.Point(72, 8)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(208, 23)
Me.TextBox1.TabIndex = 4
Me.TextBox1.Text = ""
'
'TextBox2
'
Me.TextBox2.Font = New System.Drawing.Font("宋體", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.TextBox2.Location = New System.Drawing.Point(72, 40)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(208, 23)
Me.TextBox2.TabIndex = 5
Me.TextBox2.Text = ""
'
'TextBox3
'
Me.TextBox3.Font = New System.Drawing.Font("宋體", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
Me.TextBox3.Location = New System.Drawing.Point(72, 72)
Me.TextBox3.Name = "TextBox3"
Me.TextBox3.Size = New System.Drawing.Size(208, 23)
Me.TextBox3.TabIndex = 6
Me.TextBox3.Text = ""
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.TextBox3, Me.TextBox2, Me.TextBox1, Me.Button3, Me.Button2, Me.Button1, Me.Label1})
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim strInput, Code, Record, c As String
Dim i%, length%, iAsc%
strInput = TextBox1.Text
length = Len(RTrim(strInput)) '去掉字符串右邊的空格,求真正的長度
Code = ""
For i = 1 To length
c = Mid$(strInput, i, 1) '取第i個字符
Select Case c
Case "A" To "Z" '大寫字母加序數(shù)5加密
iAsc = Asc(c) + 5
If iAsc > Asc("Z") Then iAsc = iAsc - 26 '加密后字母超過Z
Code = Code + Chr(iAsc)
Case "a" To "z"
iAsc = Asc(c) + 5 '小寫字母加序數(shù)5加密
If iAsc > Asc("z") Then iAsc = iAsc - 26
Code = Code + Chr(iAsc)
Case Else '當?shù)趇個字符為其他字符時不加密
Code = Code + c
End Select
Next i
TextBox2.Text = Code '顯示加密后的字符串
End Sub
End Class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -