Dynamic Multidimensional Arrays
I get error when I try to ReDim and Preserve a Dynamic Multidimensional Array. Code:
View RepliesI get error when I try to ReDim and Preserve a Dynamic Multidimensional Array. Code:
View RepliesI am coding an ASP script, which currently requires a 5-dimension array, i.e. array(a,b,c,d,e)
I remember reading somewhere, a long time ago, that there is a limit to the number of dimensions in ASP. That was a long time ago, and I don't remember.
I'm just confused because I'm obviously calling the code wrong but every tutorial I find makes it seem like I'm referencing the multidimensional arrays correctly so I don't knwo what I'm doing wrong. Code:
View Replies View Relatedis there any way tohave an array where the first subscript is dynamic and the second subscript is static
View Replies View Relatedi want to create a dynamic list or array in asp as we have arraylist in asp.net. what i want is that i want to hold the values selected by the user in a list and in advance i dont know that how much values the user will select. i also tried to use array with redim but that did not work as we can create array with only constant integer parameter.
View Replies View RelatedDo dynamic arrays declared using ReDim have to be freed? I assume that
if it's an array of dynamically created objects (e.g.
Scripting.Dictionary), each one of those objects will have to be set
to Nothing in a for loop, but what about the array itself?
Or what if the array is dynamic but it just consists of integers or strings, not
dynamically allocated objects? Does it have to be set to Nothing?
Do you have to manually release memory allocated by creating a dynamic array using ReDim? In other words, if I have the following code:
ReDim Test(1000)
For i = 0 To 1000
Test(i) = "test value " & i
Next
Do have I have set Test = Nothing to prevent a memory leak?
I am trying to create a dynamic multi-dimensional array, based on a count from a database. The count is correct, but when I try to Redim preserve my array, I get an error...
Subscript out of range
referring to the line of code...
ReDim Preserve builderArray(CInt(builderCount),5)
How can I do this redim successfully?
I actually work with multidimensional array (the static or dynamic one)
I've read through to use:
STATIC
=====
dim array01(2,2)
which will make an array of
(0,0) (0,1) (0,2)
(1,0) (1,1) (1,2)
right?
for DYNAMIC
=========
redim array02(2,2)
which will make exactly the same as above, but in dynamic we can extend them, right?
okay... now assume I would like to have value inside array:
array01(0,0) = "some word"
array01(0,1) = some_integer
can I do it? because when I tried to do
====
dim array01(2,2)
array01(0,0) = "test"
array01(0,1) = 5
====
it returns an error:
================
Microsoft VBScript runtime (0x800A000D)
Type mismatch
================
How do I tell ASP that the specific variable is INTEGER, or CHAR or STRING? and How do I manage my problem?
I am trying to sort a multi dimensional array but am getting an error. Can someone please help me out. Here is a sample of the array (it is created dynamically from the db): Code:
View Replies View Relatedi have a sorted array of 43 columns. dynamically altered the array and added a new row to the existing array. i need to sort the array based on 2nd column. how to sort a multidimensional array?
View Replies View RelatedI am wondering if its possible to load two array ad use one as item title and the other as value, ex:
array1 = "Sally, Jason, Jackson, Marie"
array2 = "24, 54, 21, 33"
For ....
TempSally(Sally) = 24
TempJason(Jason) = 54
....
Next....
I have a multidimensional array with 5 keys. I need to perform a alpha sort on the 3rd key. Does anyone have an example on how to do this?Here is an example of what my array consists of:
mArray(i,0) = '2007-05-02"
mArray(i,1) = "6:00pm"
mArray(i,2) = "TEXT TEXT TEXT" <------------------ NEED TO DO ALPHA
SORT ON THIS KEY ----------------<<
mArray(i,3) = 6
mArray(i,4) = 4
I have a multidimensional array that is actually 1 dimension (it comes from a recordset.getrows that returns 1 column). My goal is to put every single line of the recordset in a textfile. currently, here is my code Code:
for i = 0 to UBound(Res,2)
fileContent = fileContent & res(0,i))
Next
createTxtFile(path,fileContent)
I have 5000 lines and it takes about 10 minutes. I was thinking of doing a Array.Join but I don't think that works with multidimentional array. Also thinking of converting my useless multidimentional array into a sing dimensional array but how?
Hello all,
I am extremely stuck. I am trying to create a simple shopping cart yet keep running into the same type mismatch error everytime, no matter what I do. I have read countless articles about this, even posts in this forum, I've followed their code exactly and still I get the same error.
In the global.asa i am trying to create a multidimensional array with just two columns, product id and quantity, keeping it simple for now.
global.asa
SUB Session_OnStart
CONST CART_COLUMNS = 1
Dim cartArray()
ReDim cartArray( CART_COLUMNS, 1 )
cartMaxUsed = -1
Session("cartArray") = cartArray
Session("cartMaxUsed") = cartMaxUsed
END SUB
Now in my subsequent asp pages I have created functions to add to the array, following code exactly from articles, posts, etc., but everytime I would run them, it would fail on a type mismatch error when I tried to get the UBound of the array.
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'UBound'
/store/add.asp, line 10
So just for testing I simplified it as much as possible and it would still fail on the same line of code. Here is the code for add.asp
Dim cartArray
Dim cartMaxUsed
cartArray = Session("cartArray")
cartMaxUsed = Session("cartMaxUsed")
dim num
num= UBound(cartArray, 2)
response.write num 'for testing purposes
response.end 'only
everytime it fails at the UBound line.
i use this script to generate download links from directories which are first passed to an script to record the number a link is clicked.
the function is calle with a path like:
ListFolderContents(Server.MapPath("/dir1"))
my question now is: can i write this to an multidimensional array (or object oriented?) - and then sort it by date ?? if so how ? Code:
I code that creates a calendar for each month and then it displays events from that month that are stored in a db. I need to loop through my recordset and display all the events, but I can't quite figure out how to do it. I am thinking I need to do an array. But I am not really sure.... any ideas. Here is where you can view the calendar. Code:
View Replies View RelatedI have trouble working with arrays in asp.. I have the following error :Microsoft VBScript runtime (0x800A0009)
Subscript out of range: '[number: 0]'
the line that gives me the error is the following:
Door_OpeningValH= aDoor_OpeningVal(0)
and my code is this:
Door_OpeningVal= rs("Door_Open_Dimension")
aDoor_OpeningVal = split(Door_OpeningVal, "x", -1, 1)
Door_OpeningValH = aDoor_OpeningVal(0)
aDoor_OpeningValW = split(aDoor_OpeningVal(1)," ",-1,1)
Door_OpeningValW = aDoor_OpeningValW(0)
Door_OpeningValUnit = aDoor_OpeningValW(1)
what i'm doing is recivieng values from 2 textboxes and a combo box.I want it to save in my database like this:
2x5 ft
I need to create a multidimensional array using another int as one of the criteria but I keep getting probs with my code, what am I doing wrong?
Code:
intMonthName = Cint(Month(field_in_my_database))
Dim myarray(intMonthName,2,5)
I get this error message:
Quote: Microsoft VBScript compilation error '800a0402'
Expected integer constant
I am using ASP with VBScript and I want to know how to seperate a 2 dimensional array into 1 Dimensional arrays:
like if
MyArray is a 2 D array and I want to store the first row of this array in another array , like in C
MyArray[5][5] //this is a 2D array
OneDimArray=MyArray[0] // stores the first row of the 2D array in OneDimArray
is there a way to do it in VBScript ????
I couldn't find a way
I don't want to do it with loops I hate code with too much loops,
How can display unique values from an array. I dont want to loop thru all the values and do it. Is there a better way?.
View Replies View RelatedWhat does the numeral '1' mean in the following statement?
For J = 0 to UBound(QArray, 1)
I have an array in ASP and I am populating the array with the values from database on checking a condition. Lets say i have array of arr(5). Initially I made all the array items null ...
View Replies View RelatedI have an array in ASP called WordsArray() which contains several words. What I would like to do is search the array for a word, and if its not there, add it to another array ResultsArray()
So far, a loop in my code only checks the current array value, and not the rest of the array, adding the search word to the end of the resultsArray regardless.
I have two related tables in my database. One stores events and the other stores a list of key topics.
I have an interface set up where users can add / edit events.
In the add event page, I am querying the "key topics" table and returning them as options (array of checkboxes). The user makes their pick, and submits. All the data saves in the 'event" table, including the primary id of the "topics".
That part works great. The problem I am having is when the EDIT event page resolves, I am trying to "check" the options that were previously saved.
First thing I do (at the top of the page) is to query the events table to pull all of the data out. I use the 'events" table to do this.
For the checkboxes, I am once again looping through them in a query that uses the "key topics" table. So the boxes are displayed, but I can't seem to get the logic right to have the appropriate ones checked. here is my current code:
at the moment i am creating a shopping cart of sorts. Simply the user selects the check boxes of the items he wants and clicks submit. The items are dynamically created and they could select anything from 1 to 100 items..
so processing the form is clear not possible by hard coding. How could i read all the values from the POST into an array instead of processing each item at a time.
I have a string that looks like this: a|b|c|d%e|f| ...
I split once on "%"
ar1 = Split(Mystring, "%")
then when I try and split the ar1 by
ar2 = Split(ar1, "|")
I get error '800a000d' Type mismatch
I have tried
ar2 = Split(Cstr(ar1), "|")
How can I split this string?
I have run into a unique issue, what I want to be able to do is store a collection or array into a database or xml file. The main reason for doing this, is I don't want to use Sessions as they are volatile to server hiccups or resets. I don't want to use cookies as they are insecure, but I will use one cookie to store a UniqueID to relate to the data in the database or XML file.Can anyone think of a way to store an array in Access, MySQL, or XML file?
View Replies View RelatedI'm trying to create a table summary from SQLServer.
There are ten questions that the user must answer.
I can create the ten arrays, np, but I'm just thinking, say Question 9 never has anyone answer with the value 1, then the following step in the code (the way I see it) would fall on its face.
There are two ways round it that I can see. Test for an empty array 'index', i.e if Array9(1) = "" then ...
But my question is this, is there a way to initialise an array so that all it's values are zero? This would solve the need to test for "" later.
I have the following:
dim app_ids, irowloop, icolloop
app_ids = get_app_logins(session("stremail"))
for irowloop = 0 to ubound(app_ids, 2)
for icolloop = 0 to ubound(app_ids, 1)
response.write(app_ids(icolloop, irowloop) & ",")
next 'icolloop
response.write("|")
next 'irowloop
That returns:
0,0,bobsmith,pAssWord,|0,71,tom,tom,|0,71,tomf,pAs sWord,|1,5,tom,a1,|
Is it possible to remove the final ',' before the '|' ??
What I have is a recordset listing out a group of names. I've retrieved the field that lists the id numbers for the array and split them to a list. Then I want it to loop through the names listing trying to highlight the ids that need to be hightlighted.
What I am getting is my list repeats the names according to how many ids are in the array. So if I have 2 numbers in the array I see every name on the list twice and the two that I need selected.
I want the list to show the names one time with the correct names selected. What is wrong with this code? Code:
Is there a performance advantage to parsing thru a recordset verus using an array?
I'm currently trying to populate a listbox by returning data from my database, then either parsing thru the recordset until I reach the EOF, or putting the data into an array.
Can someone explain to me the performance implications of using Dictionaries rather than arrays? I imagine arrays are lighter but how much lighter?
View Replies View Related