Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 后台工作人员不工作_.net_Vba_Backgroundworker - Fatal编程技术网

.net 后台工作人员不工作

.net 后台工作人员不工作,.net,vba,backgroundworker,.net,Vba,Backgroundworker,您好,我需要使用vb net在我的程序上帮助backgroundworker,每次我添加backgroundworker时,程序都不会使用按钮4响应,我做错了什么 请查找我使用的以下代码: Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click BackgroundWorker1.RunWorkerAsync() End Sub Private Sub BackgroundWor

您好,我需要使用vb net在我的程序上帮助backgroundworker,每次我添加backgroundworker时,程序都不会使用按钮4响应,我做错了什么

请查找我使用的以下代码:

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
    BackgroundWorker1.RunWorkerAsync()
End Sub

Private Sub BackgroundWorker1_DoWork(sender As Object, e As ComponentModel.DoWorkEventArgs) Handles BackgroundWorker2.DoWork

    For I = 0 To 200 'Telling the program to count from 0 - 200
        runMacro()

        BackgroundWorker1.ReportProgress(I)
        System.Threading.Thread.Sleep(1000)
    Next

End Sub

Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
    ProgressBar1.Value = e.ProgressPercentage
End Sub
并找到我的runMacro()的以下代码:


按钮4\u Click()
中设置断点。它曾经被击中过吗?非常感谢,我已经解决了这个问题。在
按钮4\u Click()
中设置一个断点。它曾经被击中过吗?非常感谢,我已经解决了这个问题。
Private Sub runMacro()
    '~~> Define your Excel Objects
    Dim xlApp As New Excel.Application
    Dim xlWorkBook As Excel.Workbook

    '~~> Start Excel and open the workbook.
    xlWorkBook = xlApp.Workbooks.Open("\Projects\MV_tool\MV_tool\audit\macroaudit.xlsm")
    ' xlApp.Visible = False
    '~~> Run the macros.
    xlApp.Run("Module1.Txt_Excel_tool")
    'Source1.Close(SaveChanges:=False)
    'For i = 0 To 100
    'BackgroundWorker2.ReportProgress(i)
    ' Next
    'xlApp.Run("Module2.Txt_Excel_tool")
    '~~> Clean-up: Close the workbook and quit Excel.
    xlApp.Visible = True
    xlWorkBook.Close(False)
    'Source1.Close(SaveChanges:=False)
    '~~> Quit the Excel Application
    ' xlApp.Quit()


End Sub