📄 module1.bas
字号:
Attribute VB_Name = "Module1"
Dim Shared File$
Public Sub Quit()
If Form1!CommonDialog1.filename = "" Then End
Open Form1!CommonDialog1.filename For Input As 1
If Input(LOF(1), 1) = Form1!text1.Text Then
Close 1
End
End If
msg = "Do you wish to save ?"
Title = "Confirm Exit"
buttons = vbYesNo
response = MsgBox(msg, buttons, Title)
If response = vbYes Then
Close 1
Save
End If
End
End Sub
Public Sub Encrypt()
If Form1!Text2.Text > 9 Or Form1!Text2.Text < 1 Then
MsgBox "Please input an E-Level rating of 1 to 9."
Text2.SetFocus
Text2.Text = 0
Exit Sub
End If
Form1!CommonDialog1.Filter = "Text (*.txt)|*.txt|All Files (*.*)|*.*"
Form1!CommonDialog1.FilterIndex = 1
Form1!CommonDialog1.ShowOpen
File$ = Form1!CommonDialog1.filename
If Form1!CommonDialog1.filename = "" Then Exit Sub
Form1!text1.Text = ""
elevel% = Val(Form1!Text2.Text)
Open Form1!CommonDialog1.filename For Input As 1
Do While Not EOF(1)
A$ = Input(1, 1)
B$ = Asc(A$)
B$ = B$ + elevel%
c$ = c$ + Chr(B$)
Loop
Close 1
Form1!text1.Text = c$
Form1.Caption = "Simple Encrypt - " + Form1!CommonDialog1.filename
End Sub
Public Sub Save()
Form1!CommonDialog1.Filter = "Simple Encrypt Files (*.sef)|*.sef|Text (*.txt)|*.txt|All Files (*.*)|*.*"
Form1!CommonDialog1.filename = ""
Form1!CommonDialog1.FilterIndex = 1
Form1!CommonDialog1.ShowSave
File$ = Form1!CommonDialog1.filename
If Form1!CommonDialog1.filename = "" Then Exit Sub
Open File$ For Output As 1
Print #1, Form1!text1.Text
Close
Form1.Caption = "Simple Encrypt - " + Form1!CommonDialog1.filename
End Sub
Public Sub Decrypt()
Form1!text1.Text = ""
Form1!CommonDialog1.Filter = "Simple Encrypt Files (*.sef)|*.sef|All Files (*.*)|*.*"
Form1!CommonDialog1.FilterIndex = 1
Form1!CommonDialog1.ShowOpen
elevel = Form1!Text2.Text
If Form1!CommonDialog1.filename = "" Then Exit Sub
Open Form1!CommonDialog1.filename For Input As 1
Do While Not EOF(1)
A$ = Input(1, 1)
B$ = Asc(A$)
B$ = B$ - elevel
c$ = c$ + Chr(B$)
Loop
Close 1
Form1.Caption = "Simple Encrypt - " + Form1!CommonDialog1.filename
Form1!text1.Text = c$
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -