Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To 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 3rd, 2004, 10:01 AM
Authorized User
 
Join Date: Mar 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default Array Structure problems

Hi guys

I've got the results of a recordset that I want to equate to an array
like so

VarArray = RecordSet.GetRows

I've declared the VarArray like so

Dim VarArray() As Variant

When I query the VarArray, the structure is

VarArray(0,1)
VarArray(0,2)
VarArray(0,3) and so on

I need the structure to start at 1 and be in the following format

VarArray(1,1)
VarArray(2,1)
VarArray(3,1) and so on

I tried putting OPTION BASE 1 at the top of my module but it doesn't seem to be taking effect.

Can anyone help me out?

Cheers

Ciaran
 
Old March 3rd, 2004, 10:31 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well I am actually surprised to see someone using DAO. It caught me off guard. I looked at the help files just to verify my thoughts and that is the GetRows() method of the recordset object returns a zero based two-dimensional array. So, you are not going to be able to have the method return an array with base 1.

I wonder why you need to have a base 1 array? But, you can create another array that is based one and copy the array returned from the GetRow() method.

In regards to your statement of

VarArray(0,1)
VarArray(0,2)
VarArray(0,3) and so on

I need the structure to start at 1 and be in the following format

VarArray(1,1)
VarArray(2,1)
VarArray(3,1) and so on


Again that is not really up to you. You need to look at the documentation for the GetRows() method as it explains the way the data is returned. Once you understand that then you need to write your code accordingly.



Larry Asher
 
Old March 3rd, 2004, 11:02 AM
Authorized User
 
Join Date: Mar 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Larry

I'm actually using ADO connecting with Oracle9i to issue OLAP command and retrieve the data through RecordSets.

I have a complex Excel Add-in which uses a lot of VB code to manipulate data. The original code calls for arrays to be indexed from 1.

Thanks

Ciaran
 
Old March 3rd, 2004, 11:52 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Just create a couple of helper methods for your array.
Code:
Public Function GetItem(arr, row, column)
  GetItem = arr(row - 1, column) 
End Function
Then you can treat it as a one based array.

--

Joe
 
Old March 3rd, 2004, 12:16 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I took a second look at the MSDN help files for the ADO recordset object methods and the GetRows() method is not documented. So, out of curiosity I tried to call the GetRows() method from the ado recordset object and sure enough it's there.

I still think that you can copy the returned array into a 1 based array get what you want.



Larry Asher
 
Old March 3rd, 2004, 12:57 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

http://msdn.microsoft.com/library/de...asp?frame=true

--

Joe
 
Old March 4th, 2004, 07:10 AM
Authorized User
 
Join Date: Mar 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your replies

Cheers

Ciaran





Similar Threads
Thread Thread Starter Forum Replies Last Post
Go from 2d Array to 1d array without defining type OneQuestion General .NET 1 January 10th, 2008 11:13 AM
CSV File to Array Problems with Comma in Field MSchoaf Classic ASP Basics 1 July 19th, 2006 05:58 PM
Having problems retrieving an array to a table! penta Access 2 September 27th, 2004 07:23 AM
Array Problems Angel1701 J2EE 0 July 13th, 2004 07:50 AM
jagged array problems, who can help me? hlchuah77 C# 2 July 1st, 2004 10:37 AM





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