[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

integer array?

Posted on 2001-07-17
2
Medium Priority
?
1,004 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 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
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/…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

650 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