Wrox Programmer Forums
|
Classic ASP Components Discussions specific to components in ASP 3.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Components section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 8th, 2004, 02:55 AM
Authorized User
 
Join Date: Mar 2004
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Array

hey everyone

i want to have any array where i keep adding integers to the array..

but my problem is , each time i add sth to the array, i want to compare whether i have that integer alredat stored in the array,

if there is the same integer in teh array, it doesnt add that inetegre to the array



What Comes Around Goes Around!
__________________
What Comes Around Goes Around!
 
Old March 8th, 2004, 05:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

A "Scripting.Dictionary" object is much better suited to this task since it has the Exists() method to check whether an entry is already in there. If you're intent on using arrays you'll have to write some code yourself to check whether the value is already in the array.
 
Old March 9th, 2004, 02:39 AM
Authorized User
 
Join Date: Mar 2004
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i tried the dictionary but it is giving me an error and i dont know how to solve it cos i dont know how to deal with dictionaries..

what i want is to keep adding and ItemID to a dictionary,
everytime i add a new Id i check wther it exists or not. if yes then i dont add,,

then i need a way of retrieving the ids of the object i am storing the ids in

Is there an eas way?

pls help

What Comes Around Goes Around!
 
Old March 9th, 2004, 05:02 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

OK, maybe an example would help.
Code:
Dim ID
Dim dct
Set dct = Server.CreateObject("Scripting.Dictionary")

' you don't say where the IDs come from, so I'll use a recordset (rs) for this example
' Here we add all unique IDs into the Dictionary
Do While Not rs.EOF
    ID = rs.Fields("ID").Value
    If Not dct.Exists(ID) Then

        ' I don't know whether you want to associate anything with the IDs 
        ' so I'm just using Null here
        dct.Add ID, Null 

    End If

    rs.MoveNext
Loop

' all the unique IDs are now in the Dictionary
' to get an array of the IDs use:
someArray = dct.Keys

' to get an array of the items associated with the IDs (Nulls in this case) use:
someArray = dct.Items

' to get the item associated with a particular ID use:
someItem = dct(anyID)
hth, if not then explain a bit more what you're trying to achieve and post some of your code.

Phil
 
Old March 9th, 2004, 06:09 AM
Authorized User
 
Join Date: Mar 2004
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hey thnaks

i will try this ...

i did sth similar.. but looking at ur code.. i can see i had some errors..lol

that proves how new i am with dictionaries

thanks.
will try this an dlet u know whether it worked

What Comes Around Goes Around!
 
Old March 10th, 2004, 03:43 AM
Authorized User
 
Join Date: Mar 2004
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hey THAAAAAAAAAANKS a lot it worked



What Comes Around Goes Around!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Convering a String Array to an Integer array nkrust C# 9 November 17th, 2010 12:02 PM
Go from 2d Array to 1d array without defining type OneQuestion General .NET 1 January 10th, 2008 11:13 AM
error when sorting an Array of Array nancy VBScript 2 February 17th, 2005 12:57 PM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM
Array to Array comparison pavel Pro VB 6 0 March 24th, 2004 06:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.