Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

integer array?

Posted on 2001-07-17
2
Medium Priority
?
1,006 Views
Last Modified: 2012-06-27
Do we have integer arrays in ASP. If yes, how can i work with them?
0
Comment
Question by:rav_chow
2 Comments
 
LVL 2

Accepted Solution

by:
DirkVe earned 300 total points
ID: 6289539
Yes we have more or less. Well in fact, in ASP you don't specify of which type a variable is. But you can create an array, and you can put all types in it (also integers).

You can always do a conversion to be sure it's of the good type.

And here's a self-explaining example:


<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
Dim intArray()          ' If you don't add a number, you can change it later with ReDim

ReDim intArray(4)     ' Redimention the array

intArray(1) = CInt(1)     ' To force it to be a number, use CINT
intArray(2) = CInt(1)     ' To force it to be a number, use CINT
intArray(3) = CInt(1)     ' To force it to be a number, use CINT
intArray(4) = CInt(1)     ' To force it to be a number, use CINT
' intArray(5) = 1   ' GIVES OVERFLOW

%>
</BODY>
</HTML>
0
 
LVL 10

Expert Comment

by:makerp
ID: 6289598
heres an example of code that takes an array, some of the array variables have been set to "" and the function cleanArray removes all the emties. whilst this does not address your question specificaly it will show you a few cool things with VBScript arrays. as already stated arrays can contain any data type and even a mixture of data types, in this way it is analogus to a java vector. it is best to use conversion routines when appropriate

<%

Function cleanArray(tarr)
      arr = tarr
      FOR i = 0 TO UBOUND(arr)
            IF(arr(i) = "" AND i < UBOUND(arr))THEN
                  arr(i) = arr(i + 1)
                  arr(i + 1) = ""     
            END IF            
      NEXT
      count = 0
      FOR i = 0 TO UBOUND(arr)
            IF(arr(i) <> "")THEN
                  count = count + 1      
            END IF            
      NEXT
      REDIM PRESERVE arr(count)
      cleanArray = arr
End Function

dim arra(6)
arra(0) = "Hello"
arra(1) = "Hi"
arra(2) = "asp"
arra(3) = ""
arra(4) = "weeeee"
arra(5) = ""

'narra will now be a clean version of arra
narra = cleanArray(arra)

FOR i = 0 TO UBOUND(narra)
      Response.Write(narra(i) & "<BR>")    
NEXT

%>
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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…
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 video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

810 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