S
Shelby
Hi,
I still fail to properly end a function call with the below codes.
How can I terminate all function calls?
--------------------------------------------------------------
Connect.vb
--------------------------------------------------------------
Dim WithEvents frm1 As New ProcessForm
Private Sub Button1_Click(ByVal Ctrl As CommandBarButton, ByRef
CancelDefault As Boolean) Handles Button1.Click
frm1 = New ProcessForm
frm1.oNS = Me.oNS
frm1.oApp = Me.oApp
frm1 .Show()
End Sub
Private Sub frm1_Closed(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles frm1.Closed
frm1 = Nothing
End Sub
--------------------------------------------------------------
ProcessForm.vb
--------------------------------------------------------------
' This form has a Start and Cancel button.
' Once user click Start, it will call a function to
' perform database operation which is about 10 minutes.
' I have place a System.Windows.Forms.Application.DoEvents() in the loop of
the function,
' so that user can click Cancel and stop the process.
' The problem is when user click Cancel, the form and the database
connection is closed.
' But it is still looping in the function, because it raise an error that
there's no database connection.
' How can I resolve this problem?
Private Sub btncancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btncancel.Click
DBconn.Close()
Me.Close()
End Sub
Thanks
Shelby
I still fail to properly end a function call with the below codes.
How can I terminate all function calls?
--------------------------------------------------------------
Connect.vb
--------------------------------------------------------------
Dim WithEvents frm1 As New ProcessForm
Private Sub Button1_Click(ByVal Ctrl As CommandBarButton, ByRef
CancelDefault As Boolean) Handles Button1.Click
frm1 = New ProcessForm
frm1.oNS = Me.oNS
frm1.oApp = Me.oApp
frm1 .Show()
End Sub
Private Sub frm1_Closed(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles frm1.Closed
frm1 = Nothing
End Sub
--------------------------------------------------------------
ProcessForm.vb
--------------------------------------------------------------
' This form has a Start and Cancel button.
' Once user click Start, it will call a function to
' perform database operation which is about 10 minutes.
' I have place a System.Windows.Forms.Application.DoEvents() in the loop of
the function,
' so that user can click Cancel and stop the process.
' The problem is when user click Cancel, the form and the database
connection is closed.
' But it is still looping in the function, because it raise an error that
there's no database connection.
' How can I resolve this problem?
Private Sub btncancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btncancel.Click
DBconn.Close()
Me.Close()
End Sub
Thanks
Shelby