Click here to Skip to main content
15,919,500 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: access MDB database help Pin
Dominick Marciano5-Feb-09 4:21
professionalDominick Marciano5-Feb-09 4:21 
AnswerRe: access MDB database help Pin
Rupesh Kumar Swami5-Feb-09 4:22
Rupesh Kumar Swami5-Feb-09 4:22 
Questionretrive field value into combobox Pin
vijay24825-Feb-09 2:42
vijay24825-Feb-09 2:42 
AnswerRe: retrive field value into combobox Pin
Rupesh Kumar Swami5-Feb-09 3:11
Rupesh Kumar Swami5-Feb-09 3:11 
Question[Message Deleted] Pin
εїзεїзεїз5-Feb-09 2:07
εїзεїзεїз5-Feb-09 2:07 
AnswerRe: Grid View Control Pin
Henry Minute5-Feb-09 9:16
Henry Minute5-Feb-09 9:16 
QuestionWhere to put try / catch blocks when dealing with classes Pin
maxnuggets5-Feb-09 0:55
maxnuggets5-Feb-09 0:55 
AnswerRe: Where to put try / catch blocks when dealing with classes Pin
Johan Hakkesteegt5-Feb-09 2:09
Johan Hakkesteegt5-Feb-09 2:09 
Simply put, you have to use the Try Catch clause inside the sub or function part of your code. Like you used it in both examples. In other words, you don't have to choose. You can have your cake and eat it too.

The nice thing about vb.net's try catch clauses is that you can use several in a row within the same sub/function, and even nest them:
Private Sub BlaBlaBla()
  Try
    'some code here
    Try
      'some other code here
    Catch ex as Exception
      MsgBox(ex.ToString)
      'and/or some code here
    End Try
    'and even more code here
  Catch ex as Exception
    MsgBox(ex.ToString)
    'and/or some code here
  End Try
  Try
    'and just to make sure, some other code here
  Catch ex as Exception
    MsgBox(ex.ToString)
    'and/or some code here
  End Try
  'etc, etc, etc.
End Sub


Generally speaking, it is better to use too many try catch clauses than too few.
In classes and modules, it is a good idea to use the application event log for error reporting (
Public appLog As New System.Diagnostics.EventLog("Application", ".", appTitle)
somewhere at the top and then
appLog.WriteEntry(ex.ToString, EventLogEntryType.Error)
in the catch clause.) or a StreamWriter.

Hope this helps you.

Johan

My advice is free, and you may get what you paid for.

GeneralRe: Where to put try / catch blocks when dealing with classes Pin
maxnuggets5-Feb-09 2:22
maxnuggets5-Feb-09 2:22 
GeneralRe: Where to put try / catch blocks when dealing with classes Pin
Johan Hakkesteegt5-Feb-09 3:04
Johan Hakkesteegt5-Feb-09 3:04 
AnswerRe: Where to put try / catch blocks when dealing with classes Pin
riced5-Feb-09 4:43
riced5-Feb-09 4:43 
GeneralRe: Where to put try / catch blocks when dealing with classes Pin
supercat95-Feb-09 6:28
supercat95-Feb-09 6:28 
QuestionModifying a window service Pin
sohaib_a4-Feb-09 22:58
sohaib_a4-Feb-09 22:58 
AnswerRe: Modifying a window service Pin
Dave Kreskowiak5-Feb-09 2:23
mveDave Kreskowiak5-Feb-09 2:23 
Questionvb express list box Pin
steve moorley4-Feb-09 22:49
steve moorley4-Feb-09 22:49 
AnswerRe: vb express list box Pin
Rupesh Kumar Swami4-Feb-09 22:57
Rupesh Kumar Swami4-Feb-09 22:57 
Questioncompiling what was compiled before Pin
Member 42169604-Feb-09 22:36
Member 42169604-Feb-09 22:36 
AnswerRe: compiling what was compiled before Pin
Alan N5-Feb-09 0:25
Alan N5-Feb-09 0:25 
GeneralRe: compiling what was compiled before Pin
Member 42169605-Feb-09 0:40
Member 42169605-Feb-09 0:40 
GeneralRe: compiling what was compiled before Pin
Dave Kreskowiak5-Feb-09 2:20
mveDave Kreskowiak5-Feb-09 2:20 
GeneralRe: compiling what was compiled before Pin
Member 42169605-Feb-09 4:58
Member 42169605-Feb-09 4:58 
GeneralRe: compiling what was compiled before Pin
Dave Kreskowiak5-Feb-09 5:31
mveDave Kreskowiak5-Feb-09 5:31 
GeneralRe: compiling what was compiled before Pin
EliottA5-Feb-09 6:06
EliottA5-Feb-09 6:06 
GeneralRe: compiling what was compiled before Pin
Member 42169605-Feb-09 20:52
Member 42169605-Feb-09 20:52 
GeneralRe: compiling what was compiled before Pin
Dave Kreskowiak6-Feb-09 14:17
mveDave Kreskowiak6-Feb-09 14:17 

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.