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
Solved

VBScript array declaration not allowed by .NET framework

Posted on 2004-08-18
4
844 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
Scheduled IIS .Net2 AppPools recycle and SQL connection Hangs 33 125
Auto Submit on dropdown box 14 72
Select only the top record in a left join 13 45
Help with query 3 31
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 information …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

792 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