Click here to Skip to main content
15,898,892 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionHow to check the Status of Printer directly connected to COM port Pin
singhsunil1325-Feb-12 0:08
singhsunil1325-Feb-12 0:08 
AnswerRe: How to check the Status of Printer directly connected to COM port Pin
Dave Kreskowiak25-Feb-12 6:16
mveDave Kreskowiak25-Feb-12 6:16 
GeneralRe: How to check the Status of Printer directly connected to COM port Pin
singhsunil1325-Feb-12 20:51
singhsunil1325-Feb-12 20:51 
AnswerRe: How to check the Status of Printer directly connected to COM port Pin
Luc Pattyn26-Feb-12 3:00
sitebuilderLuc Pattyn26-Feb-12 3:00 
Questionhow to close a form instantly Pin
alejx23-Feb-12 16:35
alejx23-Feb-12 16:35 
AnswerRe: how to close a form instantly Pin
Luc Pattyn23-Feb-12 17:18
sitebuilderLuc Pattyn23-Feb-12 17:18 
QuestionSuggestion for try...Catch block Pin
alejx23-Feb-12 10:23
alejx23-Feb-12 10:23 
AnswerRe: Suggestion for try...Catch block Pin
Luc Pattyn23-Feb-12 17:30
sitebuilderLuc Pattyn23-Feb-12 17:30 
The best advice here is not to mingle GUI code and your database operations; keep them well apart, in different methods, if not different classes. And then insert try-catch blocks that catch those exceptions you can deal with, and NOT the ones you cannot handle at that level. The ones you can't handle should ripple through to the caller, hoping he would know what to do with them.

Example: if you write a method that should delete a file, you'd use File.Delete inside a try block inside a loop; the loop is needed because the delete might fail as helper programs (disk indexers, search tools, ...) might be reading the file and have it locked. So the code might look like this (in a pseudo-code which resembles C#):

deleteFile(string filename) {
    for(int tries=5; i>=0; i--) {
        try {
            File.Delete(filename);
            return;
        } catch (IOException) {
            if (i>0) Thread.Sleep(100);  // wait some
            else throw;                  // last attempt failed, rethrow the exception so the caller can catch it
        }
    }
}

In this example, "dealing with the problem" meant retrying it a couple of times.

If the retry loop is a surprise, know that Windows Explorer does this in a similar way; it is why it takes several seconds before you get a failure notice when it is unable to delete a file...


Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

GeneralRe: Suggestion for try...Catch block Pin
alejx24-Feb-12 1:57
alejx24-Feb-12 1:57 
GeneralRe: Suggestion for try...Catch block Pin
Eddy Vluggen24-Feb-12 9:49
professionalEddy Vluggen24-Feb-12 9:49 
GeneralRe: Suggestion for try...Catch block Pin
alejx25-Feb-12 7:46
alejx25-Feb-12 7:46 
GeneralRe: Suggestion for try...Catch block Pin
Eddy Vluggen25-Feb-12 8:27
professionalEddy Vluggen25-Feb-12 8:27 
GeneralRe: Suggestion for try...Catch block Pin
alejx25-Feb-12 8:34
alejx25-Feb-12 8:34 
GeneralRe: Suggestion for try...Catch block Pin
Eddy Vluggen25-Feb-12 8:41
professionalEddy Vluggen25-Feb-12 8:41 
QuestionRunning Photoshop Action Pin
Pasan14822-Feb-12 5:24
Pasan14822-Feb-12 5:24 
AnswerRe: Running Photoshop Action Pin
Simon_Whale22-Feb-12 6:06
Simon_Whale22-Feb-12 6:06 
GeneralRe: Running Photoshop Action Pin
Pasan14822-Feb-12 6:37
Pasan14822-Feb-12 6:37 
AnswerRe: Running Photoshop Action Pin
Eddy Vluggen23-Feb-12 8:46
professionalEddy Vluggen23-Feb-12 8:46 
GeneralRe: Running Photoshop Action Pin
Agecanonix23-Feb-12 10:51
Agecanonix23-Feb-12 10:51 
GeneralRe: Running Photoshop Action Pin
Dave Kreskowiak23-Feb-12 12:22
mveDave Kreskowiak23-Feb-12 12:22 
GeneralRe: Running Photoshop Action Pin
Pasan14824-Feb-12 4:36
Pasan14824-Feb-12 4:36 
Questionpassing value from popup to column gridview Pin
C#Coudou20-Feb-12 22:49
C#Coudou20-Feb-12 22:49 
QuestionLoad Connection String from a File Pin
Midnight Ahri20-Feb-12 16:14
Midnight Ahri20-Feb-12 16:14 
AnswerRe: Load Connection String from a File Pin
Luc Pattyn20-Feb-12 16:26
sitebuilderLuc Pattyn20-Feb-12 16:26 
AnswerRe: Load Connection String from a File Pin
Midnight Ahri20-Feb-12 17:12
Midnight Ahri20-Feb-12 17:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.