Solved

VBScript array declaration not allowed by .NET framework

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JQuery to parse xml string and get element by id 4 64
Hide cell in a table 2 33
Hide Table in merge 3 40
Extracting nodes  using classical ASP 3 23
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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/…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

735 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