Click here to Skip to main content
15,925,081 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Silently blocking all keyboard input for RichTextBox Pin
nlarson1114-Nov-07 7:08
nlarson1114-Nov-07 7:08 
GeneralRe: Silently blocking all keyboard input for RichTextBox Pin
supercat914-Nov-07 8:14
supercat914-Nov-07 8:14 
GeneralRe: Silently blocking all keyboard input for RichTextBox Pin
nlarson1114-Nov-07 8:21
nlarson1114-Nov-07 8:21 
GeneralRe: Silently blocking all keyboard input for RichTextBox Pin
supercat914-Nov-07 9:37
supercat914-Nov-07 9:37 
Questionhow to locate wifi node Pin
umershahbaz14-Nov-07 6:30
umershahbaz14-Nov-07 6:30 
AnswerRe: how to locate wifi node Pin
Dave Kreskowiak14-Nov-07 7:12
mveDave Kreskowiak14-Nov-07 7:12 
AnswerRe: how to locate wifi node Pin
Baddog_52017-Nov-07 16:23
Baddog_52017-Nov-07 16:23 
QuestionExeption handling in VB.net Pin
supercat914-Nov-07 6:19
supercat914-Nov-07 6:19 
I've just read Mr. Turini's article about exception-handling practices http://www.codeproject.com/dotnet/exceptionbestpractices.asp and I'm not quite clear on some things. I'm used to writing in C, with functions that return success/failure codes. While one must strive to avoid the temptation to simply ignore return codes, the use of success/failure codes allows code to progress sensibly when things don't work.

Suppose I'm reading in a bunch of dates (text format) from a file and I wish to convert them into a datetime format, using some default value if things don't work. Is there any practical alternative to writing a wrapper function to convert string->date, using a catch within the function to snag the dates that don't convert? If a generic "catch" is considered sloppy, is there a practical alternative to looking up every single function or conversion that might be expected to throw exceptions to find out exactly what exceptions it might return and risk having the application die if I miss one?

It seems to me that there are many situations, especially when accepting data from other sources, where failures are to be expected. My personal preference in such situations would be to use something akin to the IEEE floating-point NaN concept; if there's an arithmetic failure during an expression (division by zero, log of a negative number, etc.) return a sentinel value that will propagate through future expressions. Although a developer may sometimes wish for more detailed reporting of exactly why a complicated expression returns a NaN, most of the time the only thing that really matters is whether the expression evaluates or not.

Also, is there any good way in VB6 (since I'm still doing maintenance with that) or vb.net to make a program resume to the 'outer loop' when an error occurs, rather than dying altogether. If I have a button whose code is (VB6 style):

sub button1_click()
  do_some_stuff()
  a=sqr(-1)
  do_more_stuff()
end sub


it would seem perfectly logical that the error in sqr() would prevent the program from running do_more_stuff(), but I see no particular reason the program shouldn't be able to try return to a state as though the button had not been pushed. To be sure, the program might not always work correctly after that point, but allowing the option to try would seem nicer than simply having it die totally.
AnswerRe: Exeption handling in VB.net Pin
Dave Kreskowiak14-Nov-07 6:57
mveDave Kreskowiak14-Nov-07 6:57 
GeneralRe: Exeption handling in VB.net Pin
supercat914-Nov-07 9:02
supercat914-Nov-07 9:02 
GeneralRe: Exeption handling in VB.net Pin
Dave Kreskowiak14-Nov-07 10:20
mveDave Kreskowiak14-Nov-07 10:20 
GeneralRe: Exeption handling in VB.net Pin
supercat914-Nov-07 10:45
supercat914-Nov-07 10:45 
GeneralRe: Exeption handling in VB.net Pin
Dave Kreskowiak14-Nov-07 10:53
mveDave Kreskowiak14-Nov-07 10:53 
GeneralRe: Exeption handling in VB.net Pin
supercat914-Nov-07 12:05
supercat914-Nov-07 12:05 
AnswerRe: connection to SQL server stays open Pin
Dave Kreskowiak14-Nov-07 6:11
mveDave Kreskowiak14-Nov-07 6:11 
QuestionNibbles Pin
No-e14-Nov-07 6:05
No-e14-Nov-07 6:05 
AnswerRe: Nibbles Pin
Dave Kreskowiak14-Nov-07 6:26
mveDave Kreskowiak14-Nov-07 6:26 
GeneralRe: Nibbles Pin
supercat914-Nov-07 6:30
supercat914-Nov-07 6:30 
GeneralRe: Nibbles Pin
Dave Kreskowiak14-Nov-07 6:49
mveDave Kreskowiak14-Nov-07 6:49 
GeneralRe: Nibbles Pin
supercat914-Nov-07 6:56
supercat914-Nov-07 6:56 
GeneralRe: Nibbles Pin
Dave Kreskowiak14-Nov-07 7:16
mveDave Kreskowiak14-Nov-07 7:16 
GeneralRe: Nibbles Pin
supercat914-Nov-07 9:40
supercat914-Nov-07 9:40 
GeneralRe: Nibbles Pin
Dave Kreskowiak14-Nov-07 12:57
mveDave Kreskowiak14-Nov-07 12:57 
GeneralRe: Nibbles Pin
nlarson1114-Nov-07 7:40
nlarson1114-Nov-07 7:40 
GeneralRe: Nibbles Pin
Dave Kreskowiak14-Nov-07 8:22
mveDave Kreskowiak14-Nov-07 8:22 

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.