Solved

VBScript array declaration not allowed by .NET framework

Posted on 2004-08-18
4
838 Views
Last Modified: 2008-01-09
This file works when named "test.asp" but breaks when named "test.aspx".  This means that the .NET ASPX compiler is choking on perfectly valid VBScript notation.  The error message returned is "BC30684: 'Array' is a type and cannot be used as an expression."

----[code start]------------------------------------------------------------

<%
Dim arrTest : arrTest = Array( 1337 )
Response.Write( arrTest( 0 ) )
%>

----[code end]------------------------------------------------------------

This has always been legit VBScript in ASP 3.  Why does .NET no longer think so?
0
Comment
Question by:hyperslug
  • 3
4 Comments
 
LVL 31

Expert Comment

by:alorentz
ID: 11833953
VBScript is primitive.  Try this:

Dim arrTest(1337) as Array
Response.Write( arrTest( 0 ) )
0
 
LVL 31

Accepted Solution

by:
alorentz earned 50 total points
ID: 11833962
.Net works like VB, not VBScript.  I don't have .Net open so didn't test that..
0
 
LVL 3

Author Comment

by:hyperslug
ID: 11834317
Ahhh, good call.  I did try your example but I think it created an uninitialized 1,337 element array so it had no output.
But I did look up VB.NET syntax and found that this works:

<%
'Dim arrTest : arrTest = Array( 1337 )      'VBScript notation, not valid in .NET
Dim arrTest() As Integer = { 1337 }        'VB.NET notation, default @Page language
Response.Write( arrTest( 0 ) )
%>

Note the previous VBScript line is commented out.

I guess all my code has been compiling as valid VB.NET even though I thought I was coding in plain old VBScript.  Hmmm all this time.  Anyway, thanks alorentz.
0
 
LVL 31

Expert Comment

by:alorentz
ID: 11834378
Good luck!
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now