Wednesday, December 07, 2005
« Thinking outside the SQL box | Main | KB196340: How to get the WebBrowser obje... »
I ran across this code today.  This would be a good example of how NOT to dispose a dialog form.  It seems that "someone" though it would be a good idea to dispose the form only when an exception occurred?!?  Genius.  Unfortunately, I was the genius.  I should really watch my caffeine consumption!  Oh well, it's good to laugh at your own "creativity" once in a while... right? :-P

Dim frm As MyForm

Try
   frm = New MyForm
   With frm
      .StartPosition = FormStartPosition.CenterParent
      .Width = 650
      .Height = 600
      .ShowDialog()
   End With

Catch ex As Exception 'this should "probably" be "finally"
   If Not frm Is Nothing Then
      frm.Dispose()
   End If

End Try
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u)  

Enter the code shown (prevents robots):