Solved

integer array?

Posted on 2001-07-17
2
995 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 100 total points
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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 …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now