Jumping to another routine

  • Thread starter Thread starter John E. Crouse
  • Start date Start date
J

John E. Crouse

When I exit my app a confirmation message box pops up. If the user chooses
"No", what is the code I need to jump to another sub routine (So the save
file message box pops up). I already have all of the message box routine.

Thank you,
John
 
* "John E. Crouse said:
When I exit my app a confirmation message box pops up. If the user chooses
"No", what is the code I need to jump to another sub routine (So the save
file message box pops up). I already have all of the message box routine.

The name of the save routine?
 
in addition , you might want to type "Exit Sub" after calling the Other sub.

/Lars Netzel
 
* "Lars Netzel said:
in addition , you might want to type "Exit Sub" after calling the Other sub.

Or 'Exit Function', if it's a function. Or 'Return' :-).
 
Here is the place I am leaving:

Private Sub Form1_Closed(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Closed

Dim response As MsgBoxResult

response = MsgBox("Do you want quit without saving?",
MsgBoxStyle.YesNo, "CPviewer")

If response = MsgBoxResult.Yes Then

Application.Exit()

Else

'mnuSaveLayout_Click()

End If

End Sub


And here is where I want to go:

Private Sub mnuSaveLayout_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuSaveLayout.Click

SaveFileDialog1.Filter = "XML Document|*.xml"

SaveFileDialog1.Title = "Save a Layout File"

SaveFileDialog1.ShowDialog()

If SaveFileDialog1.FileName <> "" Then

Dim ds As New DataSet("CPViewer")

Dim dt1 As New DataTable("P1JoyUp")

End Sub


Thanks,
John
 
John E. Crouse said:
Here is the place I am leaving:

Private Sub Form1_Closed(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Closed

It's common usage to put the code in the Closing event and offer "yes, no,
cancel" to the user. If cancel is pressed, set e.cancel = true.
Dim response As MsgBoxResult

response = MsgBox("Do you want quit without saving?",
MsgBoxStyle.YesNo, "CPviewer")

If response = MsgBoxResult.Yes Then

Application.Exit()


Why call application.exit? It's not necessary. Only if you do not have one
specific startup form, call application.exitthread.

Else
Save

End If

End Sub


And here is where I want to go:

Private Sub mnuSaveLayout_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles mnuSaveLayout.Click
Save

End Sub

private sub Save
SaveFileDialog1.Filter = "XML Document|*.xml"

SaveFileDialog1.Title = "Save a Layout File"

SaveFileDialog1.ShowDialog()

If SaveFileDialog1.FileName <> "" Then

Dim ds As New DataSet("CPViewer")

Dim dt1 As New DataTable("P1JoyUp")
end sub


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
Back
Top