PC Review


Reply
Thread Tools Rate Thread

Class Modules

 
 
=?Utf-8?B?U1RJRw==?=
Guest
Posts: n/a
 
      2nd Jan 2007
Hi!
In a class module I have declared a matrix ( name(120,120) as double), i
have a sub procedure that does som calculations, so that I have the
information I want to use for calculations stored in that matrix. In a
generall module procedures I want to have access to a column of this matrix,
but I haven't got a clue as how to get hold of it. Preferably I would like
to assign a double variable of length 120 the contents of a column of my
choice belonging to an instance of that class.
Since the variable is of type (120,120)double I can not access it in the
usual way by the syntax object.matrix(i,j). Also, is there a way of selecting
multiple indexes in a vector? In computer algebra software such as
Matlab,S-plus or R, I am used to be able to specify a particular range of
indexes , i.e matrix(1:90,120) where 1:90 is row 1 to 90, and 120 the 120th
column. Is there any way of doing such an opperation using VBA/Excel.
Any suggestion on how to solve my problem, or links to sites where I can
read up on these matters will be greatly apprectiated.

Stig
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      2nd Jan 2007
I know of no built-in functionality to achieve it, but it should be
relatively simple to craft your own methods/properties to achieve this,
loading it into a new array and returning that.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"STIG" <(E-Mail Removed)> wrote in message
news:BDB50CE0-36AE-4E8D-B7D8-(E-Mail Removed)...
> Hi!
> In a class module I have declared a matrix ( name(120,120) as double), i
> have a sub procedure that does som calculations, so that I have the
> information I want to use for calculations stored in that matrix. In a
> generall module procedures I want to have access to a column of this
> matrix,
> but I haven't got a clue as how to get hold of it. Preferably I would
> like
> to assign a double variable of length 120 the contents of a column of my
> choice belonging to an instance of that class.
> Since the variable is of type (120,120)double I can not access it in the
> usual way by the syntax object.matrix(i,j). Also, is there a way of
> selecting
> multiple indexes in a vector? In computer algebra software such as
> Matlab,S-plus or R, I am used to be able to specify a particular range of
> indexes , i.e matrix(1:90,120) where 1:90 is row 1 to 90, and 120 the
> 120th
> column. Is there any way of doing such an opperation using VBA/Excel.
> Any suggestion on how to solve my problem, or links to sites where I can
> read up on these matters will be greatly apprectiated.
>
> Stig



 
Reply With Quote
 
Dana DeLouis
Guest
Posts: n/a
 
      2nd Jan 2007
> In computer algebra software such as
> Matlab,S-plus or R, I am used to be able to specify a particular range of
> indexes , i.e matrix(1:90,120) where 1:90 is row 1 to 90, and 120 the
> 120th


Hi. Not sure if this could help or not.
You may be able to take an entire column, but it is hard to take parts of a
single array.
Here, V is made of "All" Rows of the second Column.
Then, Redim is used to shrink the array down to the first two values.
It won't work if the index doesn't start at 1.

Sub Demo()
Dim Fx As WorksheetFunction
Dim M(), V
Const All As Long = 0

Set Fx = WorksheetFunction
M = [{1,2,3;4,5,6;7,8,9}]
V = Fx.Transpose(Fx.Index(M, All, 2))
ReDim Preserve V(1)
End Sub


It's kind of similar to math programs...
M = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};

M[[All,2]]
{2, 5, 8}

Does making your Matrix a Public variable help?
--
HTH :>)
Dana DeLouis
Windows XP & Office 2003


"STIG" <(E-Mail Removed)> wrote in message
news:BDB50CE0-36AE-4E8D-B7D8-(E-Mail Removed)...
> Hi!
> In a class module I have declared a matrix ( name(120,120) as double), i
> have a sub procedure that does som calculations, so that I have the
> information I want to use for calculations stored in that matrix. In a
> generall module procedures I want to have access to a column of this
> matrix,
> but I haven't got a clue as how to get hold of it. Preferably I would
> like
> to assign a double variable of length 120 the contents of a column of my
> choice belonging to an instance of that class.
> Since the variable is of type (120,120)double I can not access it in the
> usual way by the syntax object.matrix(i,j). Also, is there a way of
> selecting
> multiple indexes in a vector? In computer algebra software such as
> Matlab,S-plus or R, I am used to be able to specify a particular range of
> indexes , i.e matrix(1:90,120) where 1:90 is row 1 to 90, and 120 the
> 120th
> column. Is there any way of doing such an opperation using VBA/Excel.
> Any suggestion on how to solve my problem, or links to sites where I can
> read up on these matters will be greatly apprectiated.
>
> Stig



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
class modules versus modules Matt S Microsoft Excel Programming 1 12th Apr 2010 09:31 PM
Public Variables, Class Modules and Standard Modules Excel Monkey Microsoft Excel Programming 2 30th Apr 2009 03:18 PM
Class modules: parametrize class object fields Jean-Pierre Bidon Microsoft Excel Programming 11 31st Aug 2006 02:49 PM
Basic question - modules and class modules - what's the difference? Mark Stephens Microsoft Excel Programming 9 8th May 2005 11:48 AM
Class Modules vs Modules Jeff Marshall Microsoft Excel Programming 3 29th Sep 2003 02:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:19 AM.