问题如下;请老师教我啊!!!感谢啊!!!Private Sub 重来_Click()
 
 Unload Me  '将程序卸载掉
 End  Sleep 100 '等一段时间
  
 ..........  '这里再启动程序代码如何写?
 
End Sub

解决方案 »

  1.   


    在  《〈Unload Me  '将程序卸载掉〉》  前 先调用一个EXE文件这个文件的作用就是: 关闭当前的文件  延时100 在调用当前的文件当然这个EXE文件是没有窗体看不到的那种。
      

  2.   

    51365133(渊海)老师!
    那么这个EXE文件是怎么关闭程序又是怎么再调用程序的呢?
    能给个示例代码好吗?
      

  3.   

    Private Sub Form_Unload(Cancel As Integer)
    Shell "Project1.exe", vbNormalFocus
    End Sub
      

  4.   

    为了保险,将Projectl.exe 放进资源文件
    form Unload 的时候在特定目录生成 Projectl.exe 
    运行Projectl.exe
    Projectl.exe 里面
    延时100
    在调用当前的文件'代码
    Projectl.exePrivate Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Dim ExeFile As StringPrivate Sub Form_Load()
    ExeFile = Command      '在这里我把它拿来存放主程序的位置
    'Me.Visible = False     '窗体不可见,最好是再在任务管理器里面隐藏
    Sleep 100              '延时0.1秒
    Shell ExeFile, vbNormalFocus     '运行主程序
    Unload Me              '卸载窗体
    End Sub生成 Projectl.exe'-----------主程序的代码
    '将Projectl.exe添加到资源文件 资源号 101
    Private Sub Form_Load()
    If FileExist(App.Path & "\Projectl.exe") = True Then   '判断文件是否存在,位置App.path 可以换为其他位置
    Kill App.Path & "\Projectl.exe"                        '删除Projectl.exe
    End If
    End SubPrivate Sub Form_Unload(Cancel As Integer)
    'if ???????=????????? then               '如果满足???????
    Call MadFile("16384", App.Path & "\Projectl.exe", "CUSTOM", 101)
    ' "16384"为Projectl.exe 的文件大小
    ' App.Path & "\Projectl.exe" 为要生成的EXE的位置
    '后面两个就不用说了吧
    Shell App.Path & "\Projectl.exe " & App.EXEName & ".exe"       '运行
    'End If
    End Sub'判断文件是否存在
    Public Function FileExist(filename As String) As Boolean
      On Error GoTo NotExist
      Call FileLen(filename)
      FileExist = True
      Exit Function
    NotExist:
    End Function'从资源文件中生成文件 ( R=Madfile(FileSize,FileName,ResName,ResNumber) )
    Public Function MadFile(FileSize As String, filename As String, ResName As String, ResNumber As Long) As String
    On Error GoTo a:
    Dim APP2() As Byte
    Dim Counter As Long
    APP2 = LoadResData(ResNumber, ResName)
    If Dir(filename) <> "" Then
    Exit Function
    End If
    Open filename For Binary As #1
    For Counter = 0 To FileSize - 1
    Put #1, , APP2(Counter)
    Next Counter
    Close #1
    a:
    Exit Function
    End Function
    好象有点问题,有事,要出去了,自己改一下,大楷就这样