代码如下:
可能是打开文件的地方能够出错了
大虾帮帮忙!·!! 本人因此郁闷好几天了 ,先谢了
Private Sub Form_Load()
TxtPassword.PasswordChar = "*"
TxtPassword.MaxLength = 10
End Sub
Private Sub CmdBorws_Click()
CmmDlog.DialogTitle = "打开文件"
CmmDlog.Filter = "Word 文档(*,doc)|*.doc|文本文件(*.txt)|*.txt|*.*"
CmmDlog.Action = 1
TxtFile = CmmDlog.Filename
End Sub
Private Sub Cmdjmjm_Click()
Dim n%, filn$, keym$
keym = Trim(TxtPassword)
filn = Trim(TxtFile.Text)
Call Filejmjm(filn, keym)
End Sub
Private Function Encrypt(ByVal strSource As Byte, ByVal key1 As Byte) As Byte
Encrypt = strSource Xor key1
End Function
Private Sub Filejmjm(Filename As String, keym As String)
Dim char As Byte, key1 As Byte, fn As Byte
Dim n As Long, i As Integer
fn = FreeFile
Open Filename For Binary As #fn ' 可能就这里出错了
For n = 1 To LOF(fn)
Get #fn, n, char
For i = 1 To Len(keym)
key1 = Asc(Mid(keym, i, 1))
char = Encrypt(char, key1)
Next i
Put #fn, n, char
Next n
Close #fn
End Sub