473,472 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Adding Index Number to a Dynamic Array

Hi All,

I've probably done this before, but for the life of me I can't remember how
I did it. I need to move values from a DB table into an array to be used
for other queries. The number of records will vary, so I need to make the
array dynamic. Can someone remind me how I can increment the index when I
write a new record? Here's a sample of the code I wrote:

If rsGETKD.EOF = False Then
Dim KDLOTSQ
KDLOTSQ = rsGETKD.GetRows()
iRecFirst = LBound(KDLOTSQ, 2)
iRecLast = UBound(KDLOTSQ, 2)
iFieldFirst = LBound(KDLOTSQ, 1)
iFieldLast = UBound(KDLOTSQ, 1)
Dim KDLTable
MyCount = 0
For I = iRecFirst To iRecLast
MyText=""
For J = iFieldFirst To iFieldLast
MyText=MyText & KDLOTSQ(J, I)
Next
KDLTable(MyCount) = MyText
MyCount = MyCount + 1
Next
End If

What this code is supposed to do is read a DB table that contains two
values. These two values are written to another array (KDLTable) that I can
use as a reference later on in my ASP (I need to read this table four times
at four different record locations).

When I run this code, I get an "800a000d Type Mismatch" Error. Looking at
the code, the program breaks at "KDLTable(MyCount) = MyText". I'm sure the
program is failing when the system tries to use MyCount as the index number.

How can I increment the index number for each value in the table? For
example, if there are three records in the table, (ABC123, DEF456 and
GHI789), I would like to write in this manner:

KDLTable(0) = ABC123
KDLTable(1) = DEF456
KDLTable(2) = GHI789

Any ideas would be appreciated.

Thanks!

Brian.
Apr 6 '06 #1
3 1901
dim myArr()

redim preserve myArray(N)

myArray(N) = "value"


"Brian Piotrowski" <bp*********@nospam---simcoeparts.com> wrote in message
news:uc**************@TK2MSFTNGP03.phx.gbl...
Hi All,

I've probably done this before, but for the life of me I can't remember
how I did it. I need to move values from a DB table into an array to be
used for other queries. The number of records will vary, so I need to
make the array dynamic. Can someone remind me how I can increment the
index when I write a new record? Here's a sample of the code I wrote:

If rsGETKD.EOF = False Then
Dim KDLOTSQ
KDLOTSQ = rsGETKD.GetRows()
iRecFirst = LBound(KDLOTSQ, 2)
iRecLast = UBound(KDLOTSQ, 2)
iFieldFirst = LBound(KDLOTSQ, 1)
iFieldLast = UBound(KDLOTSQ, 1)
Dim KDLTable
MyCount = 0
For I = iRecFirst To iRecLast
MyText=""
For J = iFieldFirst To iFieldLast
MyText=MyText & KDLOTSQ(J, I)
Next
KDLTable(MyCount) = MyText
MyCount = MyCount + 1
Next
End If

What this code is supposed to do is read a DB table that contains two
values. These two values are written to another array (KDLTable) that I
can use as a reference later on in my ASP (I need to read this table four
times at four different record locations).

When I run this code, I get an "800a000d Type Mismatch" Error. Looking at
the code, the program breaks at "KDLTable(MyCount) = MyText". I'm sure
the program is failing when the system tries to use MyCount as the index
number.

How can I increment the index number for each value in the table? For
example, if there are three records in the table, (ABC123, DEF456 and
GHI789), I would like to write in this manner:

KDLTable(0) = ABC123
KDLTable(1) = DEF456
KDLTable(2) = GHI789

Any ideas would be appreciated.

Thanks!

Brian.

Apr 6 '06 #2
In this case, what is (N) equal to? How do I increase the value of the
index number when I read a new record? Is the REDIM statement within the
next loop for the recordset?

"Slim" <me@here.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
dim myArr()

redim preserve myArray(N)

myArray(N) = "value"


"Brian Piotrowski" <bp*********@nospam---simcoeparts.com> wrote in message
news:uc**************@TK2MSFTNGP03.phx.gbl...
Hi All,

I've probably done this before, but for the life of me I can't remember
how I did it. I need to move values from a DB table into an array to be
used for other queries. The number of records will vary, so I need to
make the array dynamic. Can someone remind me how I can increment the
index when I write a new record? Here's a sample of the code I wrote:

If rsGETKD.EOF = False Then
Dim KDLOTSQ
KDLOTSQ = rsGETKD.GetRows()
iRecFirst = LBound(KDLOTSQ, 2)
iRecLast = UBound(KDLOTSQ, 2)
iFieldFirst = LBound(KDLOTSQ, 1)
iFieldLast = UBound(KDLOTSQ, 1)
Dim KDLTable
MyCount = 0
For I = iRecFirst To iRecLast
MyText=""
For J = iFieldFirst To iFieldLast
MyText=MyText & KDLOTSQ(J, I)
Next
KDLTable(MyCount) = MyText
MyCount = MyCount + 1
Next
End If

What this code is supposed to do is read a DB table that contains two
values. These two values are written to another array (KDLTable) that I
can use as a reference later on in my ASP (I need to read this table four
times at four different record locations).

When I run this code, I get an "800a000d Type Mismatch" Error. Looking
at the code, the program breaks at "KDLTable(MyCount) = MyText". I'm
sure the program is failing when the system tries to use MyCount as the
index number.

How can I increment the index number for each value in the table? For
example, if there are three records in the table, (ABC123, DEF456 and
GHI789), I would like to write in this manner:

KDLTable(0) = ABC123
KDLTable(1) = DEF456
KDLTable(2) = GHI789

Any ideas would be appreciated.

Thanks!

Brian.


Apr 6 '06 #3
Nevermind, I see what you meant. Thanks, Slim.
"Slim" <me@here.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
dim myArr()

redim preserve myArray(N)

myArray(N) = "value"


"Brian Piotrowski" <bp*********@nospam---simcoeparts.com> wrote in message
news:uc**************@TK2MSFTNGP03.phx.gbl...
Hi All,

I've probably done this before, but for the life of me I can't remember
how I did it. I need to move values from a DB table into an array to be
used for other queries. The number of records will vary, so I need to
make the array dynamic. Can someone remind me how I can increment the
index when I write a new record? Here's a sample of the code I wrote:

If rsGETKD.EOF = False Then
Dim KDLOTSQ
KDLOTSQ = rsGETKD.GetRows()
iRecFirst = LBound(KDLOTSQ, 2)
iRecLast = UBound(KDLOTSQ, 2)
iFieldFirst = LBound(KDLOTSQ, 1)
iFieldLast = UBound(KDLOTSQ, 1)
Dim KDLTable
MyCount = 0
For I = iRecFirst To iRecLast
MyText=""
For J = iFieldFirst To iFieldLast
MyText=MyText & KDLOTSQ(J, I)
Next
KDLTable(MyCount) = MyText
MyCount = MyCount + 1
Next
End If

What this code is supposed to do is read a DB table that contains two
values. These two values are written to another array (KDLTable) that I
can use as a reference later on in my ASP (I need to read this table four
times at four different record locations).

When I run this code, I get an "800a000d Type Mismatch" Error. Looking
at the code, the program breaks at "KDLTable(MyCount) = MyText". I'm
sure the program is failing when the system tries to use MyCount as the
index number.

How can I increment the index number for each value in the table? For
example, if there are three records in the table, (ABC123, DEF456 and
GHI789), I would like to write in this manner:

KDLTable(0) = ABC123
KDLTable(1) = DEF456
KDLTable(2) = GHI789

Any ideas would be appreciated.

Thanks!

Brian.


Apr 6 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: JS | last post by:
I am trying to add an element to an array like this: var ty = ; zz = "ty"; var ab = null; zz+=""; ab = eval(zz); document.write(ab.length);
14
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB...
29
by: shmartonak | last post by:
For maximum portability what should the type of an array index be? Can any integer type be used safely? Or should I only use an unsigned type? Or what? If I'm using pointers to access array...
5
by: Steve Moreno | last post by:
Hi all, I've got a web form that I've written code to create an array of DropDownList controls on the page depending on how many records are pulled back. The code to create the controls is...
14
by: Paul_Madden via DotNetMonster.com | last post by:
Basically I have a listbox to which I add simple STRING items- I have a progress bar which I increment whenever I populate another portion of the complete set of items I wish to add. What I observe...
0
by: EricLondaits | last post by:
Hi, I have an ASP.NET page with a ListBox that is data bound to a table with a single field (it holds a list of valid IDs). The page also has a textBox into which you can add new valid IDs, one...
3
by: Nunzio | last post by:
I am trying to add specific form controls to a VBA collection, so that I can pass the entire collection to another function, and access the individual controls later. I have tried several...
1
by: Deadvacahead | last post by:
I am rather new to programming and am coming across a problem with my current program. The program shows bins full of parts. It shows the name of the bin and then how many parts are in the bin. The...
4
by: ndedhia1 | last post by:
I am reading in a file to see what delays I am getting on what IP address: QuoteBlockTiming exceeded 1000 ms: 1684 --- Fri Nov 06 06:09:10 CST 2009 170.137.94.95 Class key = 649126730 block...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.