Variable '<variablename>' hides a variable in an enclosing block
TOC
Collapse the table of content
Expand the table of content

Variable '<variablename>' hides a variable in an enclosing block

 

A variable enclosed in a block has the same name as another local variable.

Error ID: BC30616

To correct this error

  • Rename the variable in the enclosed block so that it is not the same as any other local variables. For example:

    Dim a, b, x As Integer
    If a = b Then
       Dim y As Integer = 20 ' Uniquely named block variable.
    End If
    
  • 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.

  • Another common source of this error is an attempt to access a local variable declared within a Try block in a separate Catch block. To correct this, declare the variable outside the Try...Catch...Finally structure.

Show:
© 2016 Microsoft