W
wang_guojian
Unregistered / Unconfirmed
GUEST, unregistred user!
那位能帮我把以下的 VB程序调试成功您将获得200分。(改装成DELPHI也行)<br>谢谢!!!<br>“问题出在 Private Sub C_OK_Click() 调用FINDFIRSTFILEA( )时”<br>Private Type FILETIME<br>DWLOWDATETIME As Long<br>DWHIGHDATETIME As Long<br>End Type<br><br>Private Type WIN32_FIND_DATA<br>DWFILEATTRIBUTES As Long<br>FTCREATIONTIME As FILETIME<br>FTLASTACCESSTIME As FILETIME<br>FTLASTWRITETIME As FILETIME<br>NFILESIZEHIGH As Long<br>NFILESIZELOW As Long<br>DWRESERVED0 As Long<br>DWRESERVED1 As Long<br>CFILENAME As String * 256<br>CALTERNATE As String * 14<br>End Type<br>Private Declare Function FINDFIRSTFILE Lib "KERNEL32" Alias "FINDFIRSTFILEA" (ByVal LPFILENAME As String, LPFINDFILEDATA As WIN32_FIND_DATA) As Long<br><br><br>Private Declare Function DELETEFILE Lib "KERNEL32" Alias "DELETEFILEA" (ByVal LPFILENAME As String) As Long<br><br><br><br><br><br>Private Sub C_EXIT_Click() ‘退出按钮<br>Unload Me<br>End Sub<br><br>Private Sub C_OK_Click() ’确定按钮<br>If T_SOURCEFILE.Text = " " Then<br>MsgBox "必须有源文件名!", vbQuestion, "注意:"<br>T_SOURCEFILE.SetFocus<br>Exit Sub<br><br>End If<br><br>If T_TARGETFILE.Text = " " Then<br>MsgBox "必须有目标文件名!", vbQuestion, "注意:"<br>T_TARGETFILE.SetFocus<br><br>End If<br><br>If T_SOURCEFILE.Text = T_TARGETFILE.Text Then<br>MsgBox "源文件[路径和文件名]不能与目标文件[路径和文件名]相同!", vbOKOnly, "注意:"<br>T_SOURCEFILE.SetFocus<br>Exit Sub<br><br>End If<br><br>If T_ENCODE.Text <> T_CONFIRMENCODE.Text Then<br>MsgBox "确认密码不对!", vbQuestion, "注意:"<br>T_ENCODE.SetFocus<br>Exit Sub<br><br>End If<br><br>Dim FILEDATA As WIN32_FIND_DATA<br>If FINDFIRSTFILEA(T_SOURCEFILE.Text, FILEDATA) = -1 Then<br>MsgBox "源文件不存在!", vbOKOnly, "注意:"<br>T_SOURCEFILE.SetFocus<br>Exit Sub<br><br>End If<br><br>Dim LENGTH As Integer<br>Dim I As Long<br>Dim ENCODE As Long<br>LENGTH = Len(T_ENCODE)<br><br>If LENGTH = 0 Then<br>ENCODE = -30<br>Else<br><br>For I = 1 To LENGTH<br>ENCODE = ENCODE + Asc(Mid(T_ENCODE, I, 1)) * 256 * I<br>Next I<br>ENCODE = -ENCODE<br>End If<br><br>Dim FN1 As Long<br>Dim FN2 As Long<br>FN1 = FreeFile<br>Open T_SOURCEFILE.Text For Binary Access Read As #FN1<br>FN2 = FreeFile<br>Open T_TARGETFILE.Text For Binary Access Write As #FN2<br>Form1.MousePointer = 11<br>ProgressBar1.Visible = TYUE<br>Dim FLENGTH As Long<br>Dim SIZE As Long<br>Dim BYTEBLOCK() As Byte<br>Dim POSITION As Long<br>Dim J As Long<br><br>FLENGTH = LOF(FN1)<br>SIZE = 32768<br>POSITION = 0<br>Rnd (ENCODE)<br>Do While POSITION < FLENGTH<br>If FLENGTH - POSITION < SIZE Then SIZE = FLENGTH - POSITION<br>ReDim BYTEBLOCK(1 To SIZE)<br>Get #FN1, POSITION + 1, BYTEBLOCK<br>For J = 1 To SIZE<br>BYTEBLOCK(J) = BYTEBLOCK(J) Xor Int(Rnd * 256)<br>Next J<br>Put #FN2, POSITION + 1, BYTEBLOCK<br>POSITION = POSITION + SIZE<br>ProgressBar1.Value = Int(POSITION / FLENGTH * 100)<br>Loop<br>Close FN1, FN2<br>If CB_DEL Then DELETEFILE (T_SOURCEFILE)<br>ProgressBar1.Visible = False<br>Form1.MousePointer = 0<br>MsgBox "加密/解密完毕!", vbOKOnly, "注意:"<br>End Sub<br><br>Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)<br><br>End Sub<br><br><br>Private Sub T_SOURCEFILE_DblClick() ’文本框一<br>CommonDialog1.DialogTitle = "打开源文件名:"<br>CommonDialog1.Filter = "所有文件(*.*)|*.*|*.JM文件|*.JM"<br>CommonDialog1.ShowOpen<br>If CommonDialog1.FileName <> " " Then<br>Dim LENGTH As Integer<br>Dim EXNAME As String<br>LENGTH = Len(CommonDialog1.FileName)<br>EXNAME = Mid(CommonDialog1.FileName, LENGTH - 3 + 1)<br>T_SOURCEFILE.Text = CommonDialog1.FileName<br>If UCase(EXNAME) = "JM" Then<br>T_TARGETFILE.Text = Mid(CommonDialog1.FileName, 1, LENGTH - 3)<br>Else<br>T_TARGETFILE.Text = CommonDialog1.FileName + ".JM"<br>End If<br>End If<br><br>End Sub<br><br>Private Sub T_TARGETFILE_DblClick() ‘文本框二<br>CommonDialog1.DialogTitle = "打开目标文件名:"<br>CommonDialog1.Filter = "所有文件(*.*)|*.*|*.JM文件|*.JM"<br>CommonDialog1.ShowOpen<br>If CommonDialog1.FileName <> " " Then<br>T_TARGETFILE.Text = CommonDialog1.FileName + ".JM"<br>End If<br><br>End Sub<br>