【正确答案】正确答案:根据题意,将两个命令按钮和一个文本框控件添加到窗体中,命令按钮的名称分别为Commandl和Command2,Caption分别为“读取”和“加密保存”,文本框的名称为Textl,MultiLine属性为True、Scrollbars属性为2。设计完成后编写如下代码: Dim str As String Private Sub Commandl_Click() str="" Dim trap As String Open"App.Path&\in5.txt"For
Input
As#l While
EOF(1)=False
Input#1,tmp'逐行读取文件 str=str+tmp'将读取到的字符放入str字符串中 Wend Close#1 Textl.
Text
=str '在Textl中显示字符串 End Sub Private Sub Command2_Click() str="" Dim tmp As String For i=1 To
Len(Text1.Text)
tmD=Mid(Textl.
Text
,i,1) '通过Mid函数一个一个读入字符 If Asc(tmp)<=Asc("z")And Ase(tmp)>=Asc("A")Then If Asc(tmp)<=Asc("z")And Asc(tmp))>=Asc("a")Then '当输人为小写字母时 tmp=Chr((Asc(tmp)-1-Asc("a")+26)Mod 26+Asc("a")) Else'当输入为大写字母时 tmp=Chr((Asc(tmp)-1-Asc("A")+26)Mod 26+Asc("A")) End If End If str=str+tmp'将字符串连起来 Next i Open"App.Path&\out5.txt"For Output As#2 Print#2,str Close#2 End Sub 单击
