The issue here will be the scope of the variable.
Take this example, we have a one variable called testvar but it's defined in two different scopes, the first is in the Global Scope and the second is in the Local Scope of a Sub Procedure.
Option Explicit
'Variable declared in the global scope will be available to any procedure
'wishing to use it.
Dim testvar: testvar = "global"
Call Test()
Call Test2()
Call Response.Write(testvar & "<br />") 'Will equal "global changed"
Sub Test()
Call Response.Write(testvar & "<br />") 'Will equal "global"
'Updating the global variable.
testvar = "global changed"
End Sub
Sub Test2()
'Variable declared in the local scope and will only be available
'to the procedure it is declared in.
Dim testvar: testvar = "local"
Call Response.Write(testvar & "<br />") 'Will equal "local"
End Sub
Output:
global
local
global changed
Where this could get confusing is when the testvar declarations are not defined correctly causing ambiguity.
Just remember variables declared inside a Sub / Function are only available to that Sub / Function and cannot be used outside the scope of that Sub / Function.
Variables declared outside of a Sub / Function also known as Global Scope (not always the case if we start talking about Classes, but lets keep it simple for now) are available to any Sub / Function and can be called anywhere in a page (including from #include as this is just the extension of the existing pages code).
Useful Links
Option ExplicitandDimto make sure that all your variables are declared and scoped correctly. What I mean by scope is for example if you have have variables declared usingDiminside aSubprocedure they will only be available inside that procedure. To make them available outside the procedure declared them outside usingDim. This is also Unknown as globally defining variables. Take a look here for my information on variable declaration and scope.