我有一个看起来工作正常的小型 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