When copying and pasting a bit of sample code from MSDN, I came up with the error in the title - Variable '' hides a variable in an enclosing block,
All I copied was a very basic example of a try loop.
As it says in the suggestion "A common cause for this error is the use of Catch e As Exception inside an event handler. If this is the case, name the Catch block variable ex rather than e."
So, I did that, changed both e
to ex
and it worked, however, I don't understand why this doesn't cause the same error.
Can someone please explain better what the error is and why e causes it, and ex doesn't?
edit -
code example...
Try
Catch e As Exception
msgbox(e.Message)
End Try
.
Try
Catch ex As Exception
msgbox(ex.Message)
End Try
What I don't understand is why the first one causes the problem and the second one doesn't, to me, it is like... Using apples above, apple below - saying you can't use the same thing in both places, then changing both to oranges and suddenly letting it work. Surely the second is doing the same as the first.