Solved

integer array?

Posted on 2001-07-17
2
1,001 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
[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
2 Comments
 
LVL 2

Accepted Solution

by:
DirkVe earned 100 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

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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/…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 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