shankar_it Posted August 5, 2005 Posted August 5, 2005 Do any one know a command to completly stop the program running . I have a for loop which has a try and catch function For Each MyFile In FilesArray Try MyFile.Delete() Catch ex As Exception MessageBox.Show("close all other wondows a run the program again", "DocumentManager Information", MessageBoxButtons.OK, MessageBoxIcon.Information) Application.Exit() End Try Next MyFile i use application.exit() to end the program ,but the program runs till "for loop" ends. ie if the looop goes into catch 2 times then it displays the message box twice. Is there any other command to stop the program from completly running the first time enters the catch.I use vb.net for programming. Quote
Simcoder Posted August 5, 2005 Posted August 5, 2005 Just Use "Exit For" After The Messagebox Inside Your Catch Block For Each MyFile In FilesArray Try MyFile.Delete() Catch ex As Exception MessageBox.Show("close all other wondows a run the program again", "DocumentManager Information", MessageBoxButtons.OK, MessageBoxIcon.Information) Exit For Application.Exit() End Try Next MyFile -=Simcoder=- Quote Whatever thy hand findest to do, do it with all thy heart - Jesus
Joe Mamma Posted August 5, 2005 Posted August 5, 2005 actually: Try [indent]For Each MyFile In FilesArray [indent]MyFile.Delete() [/indent] next MyFile [/indent]Catch ex As Exception [indent]MessageBox.Show("close all other wondows a run the program again", "DocumentManager Information", MessageBoxButtons.OK, MessageBoxIcon.Information) Application.Exit() [/indent] End Try Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
shankar_it Posted August 5, 2005 Author Posted August 5, 2005 joe yourcode was very helpfull since i was using this for loop inside a funtion and i do call this function 3 times in the same program.I have used try catch whenever i call this function instead of using it in for loop.since i am new to java and VB.net i really don't know much about try catch. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.