troubleshooting Question

How to "undim" a variable

Avatar of GrrWolfie
GrrWolfieFlag for United States of America asked on
ASPASP.NETVB Script
11 Comments3 Solutions2044 ViewsLast Modified:
I'm building a dynamic website with ASP file Includes, i'm running into "Name redefined" errors as sometimes two files will Dim the same variable (and I want to use Option Explicit). I REALLY don't want to give each file unique variable names as it'll be hell to copy paste code pieces around.

Example:
file1.asp:
<%
Dim somedata
somedata="hello!"
Set somedata=Nothing
%>
file2.asp:
<%
Dim somedata
somedata="goodbye!"
Set somedata=Nothing
%>
index.asp:
<!--#INCLUDE FILE="file1.asp" -->
<!--#INCLUDE FILE="file2.asp" -->
Output:
Microsoft VBScript compilation (0x800A0411)
Name redefined

Also I understand Subs and Functions will delete internally declared variables after losing scope, i'm looking for a more robust solution.

Thanks in advance!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 3 Answers and 11 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros