简体   繁体   中英

Is it possible to define same variable twice in classic ASP?

Is it somehow possible to declare same variable in .asp file twice? Example below does not look very clever, but this is just an example and I have to sort it out.

Dim number : number = 1

Select Case number
    Case 1
        Dim a
    Case 2
        Dim a
End Select

Theoretically you can of course declare a variable twice, the problem is, asp will throw an error, if the variable is declared in the same scope.

whatever you want to achieve, keep in mind, you can (almost) always access the variables in parent scope, thus rendering a double declaration useless.

Dim number : number = 1
Dim a
Select Case number
   Case 1:
      a = "whatever"
   Case 2:
      a = "something different"
End Select
response.write a

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM