469,317 Members | 1,739 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,317 developers. It's quick & easy.

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 1733
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

14 posts views Thread by Sean C. | last post: by
29 posts views Thread by shmartonak | last post: by
14 posts views Thread by Paul_Madden via DotNetMonster.com | last post: by
reply views Thread by EricLondaits | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.