How to abort run before Application.Run

  • Thread starter Thread starter YXQ
  • Start date Start date
Y

YXQ

I want to abort the code to run before Application.Run, only use "End"? but
if use "End", the Application.Restart will not work, are there better ways?
thank you.
 
YXQ said:
I want to abort the code to run before Application.Run, only use
"End"? but if use "End", the Application.Restart will not work, are
there better ways? thank you.

I guess you wrote your own Sub Main, right? Either don't execute
Application.Run in every circumstance or execute Return.

If .. then
application.run
end if
or
if ... then return
application.run


Armin
 
Thank you for your reply, but my code like:
/////////////////////////////////////////////////////////
Public Sub Main()
if ....Then End
End If
Dim objFrm As New form1
objFrm.Show()
Application.Run()
End Sub
//////////////////////////////////////////////////////////
If..., i want to exit program fully, only can use End? if use End, the
appliation.Restart will not work, what replace End? Thank you.
 
YXQ said:
Thank you for your reply, but my code like:
/////////////////////////////////////////////////////////
Public Sub Main()
if ....Then End
End If
Dim objFrm As New form1
objFrm.Show()
Application.Run()
End Sub
//////////////////////////////////////////////////////////
If..., i want to exit program fully, only can use End? if use End, the
appliation.Restart will not work, what replace End? Thank you.

Sorry, I misread the question. Probably because I didn't know that there is
an application.restart method. I'm afraid, I can't help you with that.


Armin
 
You haven't inicated whether the restart shuld occur in every circumstance,
or only occurs in a specific case, but it seems that the answer to your
question is to not execute the End when you want the application restarted.

Public Sub Main()
If <application should not run> Then
If <application should be restarted>
Application.Restart
End If
End
End If
Dim objFrm As New form1
objFrm.Show()
Application.Run()
End Sub
 
Back
Top