?
Solved

How to shut my program down if I can load an xml document

Posted on 2008-10-29
5
Medium Priority
?
139 Views
Last Modified: 2010-05-18
I want to exit out of my program the xml source file does not exist.


somthing like--
 
'Read from xml file
Try
XmlReader.Create(xmlLoc)
Catch ex As Exception
MessageBox.Show("Could not create file" & vbCrLf & ex.Message)
Finally
e.Cancel = True
End Try

Open in new window

0
Comment
Question by:gvilla23
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 17

Expert Comment

by:Daniel Reynolds
ID: 22836839
after the End Try

End
0
 

Author Comment

by:gvilla23
ID: 22836857
I have code after that so it gives me green squiggly lines after the End.
0
 
LVL 13

Expert Comment

by:numberkruncher
ID: 22836869
Personally I would unload the main application form. I would not recommend terminating the application abruptly.

You will want to compare against your cancel value, otherwise the code suggested above will end your program whether the XML file was loaded or not.
'Read from xml file
Try
   XmlReader.Create(xmlLoc)
Catch ex As Exception
   MessageBox.Show("Could not create file" & vbCrLf & ex.Message)
Finally
   e.Cancel = True
End Try
 
If e.Cancel Then
   End
   ' Or better still uncomment the following line
   ' Unload Me
End If

Open in new window

0
 

Author Comment

by:gvilla23
ID: 22836922
I get a blue squiggly line under unload.
0
 
LVL 13

Accepted Solution

by:
numberkruncher earned 200 total points
ID: 22836936
Sorry, for some strange reason I thought you were using VB6.

You want to close the current form.

Me.Close

If you get a blue squiggly under that try just Close. You will have to excuse my VB2005+ skills.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question