📄 例[6-22].frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "例[6-22] 加密程序"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 3675
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 3675
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "加密"
Height = 495
Left = 2400
TabIndex = 6
Top = 2160
Width = 855
End
Begin VB.CheckBox Check1
Caption = "密文隐藏"
Height = 375
Left = 2520
TabIndex = 5
Top = 840
Width = 1095
End
Begin VB.Frame Frame1
Caption = "移动位数"
Height = 1455
Left = 120
TabIndex = 4
Top = 1560
Width = 1695
Begin VB.OptionButton Option3
Caption = "3"
Height = 255
Left = 240
TabIndex = 9
Top = 960
Width = 855
End
Begin VB.OptionButton Option2
Caption = "2"
Height = 255
Left = 240
TabIndex = 8
Top = 600
Width = 855
End
Begin VB.OptionButton Option1
Caption = "1"
Height = 255
Left = 240
TabIndex = 7
Top = 240
Width = 855
End
End
Begin VB.TextBox Text2
Height = 375
Left = 840
TabIndex = 3
Top = 840
Width = 1575
End
Begin VB.TextBox Text1
Height = 375
Left = 840
TabIndex = 2
Top = 240
Width = 1575
End
Begin VB.Label Label2
Caption = "密文"
Height = 495
Left = 120
TabIndex = 1
Top = 960
Width = 735
End
Begin VB.Label Label1
Caption = "明文"
Height = 375
Left = 120
TabIndex = 0
Top = 360
Width = 735
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 n As Integer, k As Integer, m As Integer, c As String, a As String
If Option1.Value = True Then '加密时字母的移动位数放入n
n = 1
ElseIf Option2.Value = True Then
n = 2
Else
n = 3
End If
m = Len(Text1.Text)
a = ""
For k = 1 To m
c = Mid(Text1.Text, k, 1) '从字符串中逐个取出字母进行加密
c = Chr(Asc(c) + n)
If c > "z" Or c > "Z" And c < "a" Then
c = Chr(Asc(c) - 26)
End If
a = a + c
Next k
Text2.Text = a
End Sub
Private Sub Check1_Click()
If Check1.Value = 1 Then
Text2.PasswordChar = "*" '密文显示为*
Else
Text2.PasswordChar = ""
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -