?
Solved

VBScript array declaration not allowed by .NET framework

Posted on 2004-08-18
4
Medium Priority
?
866 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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 informatio…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

765 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