 Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As _
               System.EventArgs) Handles btnStart.Click
 
   Dim i As Integer, ValidErrors As Integer

   On Error GoTo ShowError    ' Aktywujemy obsługę błędów

   ValidErrors = 0
   txtOutput.Text = ""
   For i = 0 To 1000    ' Kody błędów poniżej 1000 są zarezerwowane 
     Err.Raise(i)
     lblProgress.Text = "Processing error number: " & CStr(i)
     Me.Update()
   Next i
   lblProgress.Text = "Total useable error messages: " & _
   CStr(ValidErrors)
   Exit Sub

 ShowError:

   If Err.Description <> UNUSED_ERROR_NUMBER Then
     txtOutput.Text &= Format(Err.Number, "000") & _ 
                " " & Err.Description & vbCrLf
     ValidErrors += 1
   End If
   Resume Next

 End Sub
