2013-03-03 47 views
0

我有一个看起来工作正常的小型VB项目,除非我在某个函数中显示任何表单。当程序执行结束时导致VB进程不能结束的形式

在下面的代码中,显示了form_progress(稍后在函数中隐藏),但是当执行时(所有表单都关闭),进程并没有结束,并且通常我被困在调试中,除非我手动结束它。请注意,如果我注释掉form_progress.Show(),则在所有表单关闭后,该过程将按预期结束。

起初我主要关注form_progress表单的问题,但它不是 - 我在此处显示的任何表单都会导致此问题。没有错误被抛出,所以我迷失在哪里看。如果有人有任何建议,我会appriciate它。谢谢。

Public Sub complete_action(folder As String, rename As Boolean, include_sub_folders As Boolean) 

    Dim dir As DirectoryInfo   ' The directory that they user selected as an object 
    Dim output As String    ' The output to be placed in the log 

    ' Set 'output' to be an empty string (to avoid errors) 
    output = "" 

    Try 

     form_progress.Show() 

     ' Set the DirectoryInfo object from the users selected directory name 
     dir = New DirectoryInfo(folder) 

     If include_sub_folders Then 
      output = recursive_loop(dir, rename, output) 
     Else 
      output = loop_folder(dir, folder, rename) 
     End If 

     ' Write the log file 
     write_text.Log_File.write_to_file(output) 

     form_progress.Hide() 

    Catch oError As Exception 
     functions.error_handler(oError, "Error when looping through files", "complete_action") 
    End Try 

End Sub 

回答

1

尝试使用form_progress.Close()而不是Hide()。

+0

当然,谢谢。我完全是盲目的,因为我关注的是形式被视为问题的原因! – 2013-03-03 12:21:40