'System.Windows.Forms.Control.x' is not accessible in this context because it is 'Private'.
'System.Windows.Forms.Control.y' is not accessible in this context because it is 'Private'.
Name 'Z' is not declared.
These messages don't point very directly to what's wrong, so let's just get right to the problem. Both the Try and the Catch blocks are separate coding blocks in VB.NET and can't share variables unless you code them to do that. So, because X, Y, and Z are declared in the Try block, they are not available in the Catch block. To solve the problem, just move them outside both blocks.
~~~~~~~~~~~~~~~~~~~~~~~~~
Dim X, Y, Z As Integer
Try
' The traditional Divide By Zero error
X = 1 : Y = 0
Z = X / Y
Catch ex As Exception
Debug.WriteLine("exception using X, Y, and Z values" _
& vbCrLf & vbTab & X & Y & Z)
End Try
~~~~~~~~~~~~~~~~~~~~~~~~~

