Redim Preserve

I'm trying to build an array with the ID's of the users I have in a Mysql table called tbl_user.
Here is what I coded :

dim listeId(1)
i = 0
Set rs=Conn.Execute("SELECT ID from tbl_user ORDER BY Id;")
Do While Not rs.EOF
if i = 0 then
listeId(i)= rs("ID")
else
REDIM PRESERVE listeId(i+1)
listeId(i)= rs("ID")
end if
i = i + 1
rs.MoveNext
Loop
rs.close

But I get this error: (0x800A000A)
which is something like "fixed or temporary locked array"

View Replies


ADVERTISEMENT

Redim Preserve MyArray(i)

Is it correct to think that after reducing the populated array's size from say, 10 to 5 with redim preserve myArray(i) an attempt to access an element above the fifth does not cause a compillation error "array out of script", but returns whatever heppened to
be written in that memory address (in particular it might return the correct values of those elements before re-dimentioning)?This seems to be the case in my code, yet I wanted to make sure that this isnot the result of some other side effect.

View Replies View Related

ReDim And Preserve For An ASP Array

I am implementing a site where an admin user can log purchases of items into a DB.
Obviouslt, one purchase can consist of many items. I am therefore trying to implement a 'Cart' idea wherby the user adds the items to be purchased to the cart and then completes the purchase once all items have been added to the cart.

i aM IMPLEMENTING THE CART FUNCTIONALITY VIA AN asp ARRAY. nOW I CAN Do THIS NO PROBLEM, APART FROM THE FACT THAT, i declare an array of size 10, with 5 attributes to each element. i.e.

Dim purchaseCart(10,4)

The problem is, i want to be able to ensure that if the user decides to purchase more then 10 items, that the array can be ReDimensioned to suit i.e. increase size by one every time another element is added, after it has reached its maximum size!! Code:

View Replies View Related

REDIM Preserve "Out Of Range"

REDIM Preserve reports an "out of range".

I first create an array, store it into a session var then, in other page, I load restore the session var into a local array but, after this, I can't REDIM Preserve.

View Replies View Related

Preserve Zeros

How can I read back info from a database into an input field (in case it's to be edited) that will preserve the zeros to the right of the decimal?The zeros are being preserved in the access database when I have a look at it there. I have the field defined as type "Currency" to two decimal places.

I want to preserve those zeros to the right of the decimal point when I read the record into an input tag on a web page.I am trying to use "FormatCurrency(request.form(exp, 2))" and "FormatNumber(request.form(exp, 2))" but it doesn't help.

View Replies View Related

ReDim Array

How an earth does this reDim of an array work ? I am looping through 1 array using a for loop and rediming an array within there. Code:

View Replies View Related

Redim Array In For Each Loop

I'm trying to build a piece of code that loops through the Request.Form collection, takes the "name" part of the name/value pair of each Item in the Request.Form collection, splits them into an array based on a common Form Field naming convention, and outputs the result (the full code will do much more - I'm just trying to build this in "baby steps").
Ex:

If my Form field names are:

t_FirstName
t_LastName
i_StateOfResidence

I wrote this code to loop through these, split them based on the underscore character ("_"), and output the results: Code:

View Replies View Related

Preserve Line Breaks

I've got the following code which should write the contents of a textarea to a '.txt' file:

Code:

set objFileSystem = server.createobject("Scripting.FileSystemObject")
set objFilePlainText = objFileSystem.CreateTextFile(server.mappath("templates/my-text-file.txt"),true)

objFilePlainText.write(strTemplatePlainText)

If I response.write this data before inserting to the txt file, it preserves the line breaks, but when it writes to the txt file it seems to lose all of the line breaks.
Does anyone know how to get this to preserve the formatting of the text being inserted?

View Replies View Related

Preserve Input Fields

I have a .asp form page that submits to another .asp page that uses cdonts to send me an email and does a response.redirect back to the form page. I need to preserve (keep) a couple of text box values and a couple of dropdown box values.

At this point I have global.asa variables for the fields in question and they are all set to null. I can't figure out how to put the contents back in the fields, when it returns from the cdonts page. I assume that I must save all the field values in the session variables just prior to the submit to the cdonts page.

show me how to accomplich this for one text field called name and one dropdown box called PUDeliv?

View Replies View Related

How Can I "ReDim" A Two-dimensional Array?

I guess one should declare the array using empty brackets.

Dim MyArray()

Later I set MyArray to:

Redim MyArray(2,3)

The problem comes now. How should I use Redim again? I have heard that only one of the two dimensions can be enlarged or decreased. Is that correct? If so, which dimension would be ok to set to 5 in MyArray. Is ReDim MyArray (2,5) correct or should it be (5,2)?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved