Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using a matrix and class design


I am struggling with how to use a matrix(?) to feed my class
the code in sub Main doesnt work and i dont know how to fix it or how
to use the data passed to the AddEntry sub.

Any help greatly appreciated.


Class:
Private Entries As Collection
Private mAcctNo As String
Private mDebit As Integer
Private mCredit As Integer

Public Sub Main(data As Variant)
Dim i As Integer

For i = 1 To data.Length
AddEntry data(1)
Next i
End Sub
Private Sub AddEntry(entry As Variant)
Dim Je As JournalEntry
Set Je = New JournalEntry
Je.acctNo entry(1)
Je.Debit = entry(2)
Je.Credit = entry(3)
Entries.Add (Je)
End Sub
Public Property Let acctNo(val As String)
mAcctNo = val
End Property
Public Property Let Credit(val As Integer)
mCredit = val
End Property
Public Property Let Debit(val As Integer)
mDebit = val
End Property
------------------------------------------------
calling code:

Sub getstuff()
Dim vMatrix As Variant
Dim rngLastRow As Range

'a handle on the range we are working with
With ActiveSheet.Range("A:C")

'get the LastRow
Set rngLastRow = .Find(what:="*", searchorder:=xlByRows,
searchdirection:=xlPrevious)

'if the range contains data then populate our variant array
If Not rngLastRow Is Nothing Then
vMatrix = .Resize(rngLastRow.Row - .Row + 1, .Columns.Count)
End If

End With
Dim Je As JournalEntry
Set Je = New JournalEntry
Je.Main (vMatrix)

End Sub


--
mikezx10
------------------------------------------------------------------------
mikezx10's Profile: http://www.thecodecage.com/forumz/member.php?userid=331
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=98254

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using a matrix and class design


mikezx10;351065 Wrote:
I am struggling with how to use a matrix(?) to feed my class
the code in sub Main doesnt work and i dont know how to fix it or how
to use the data passed to the AddEntry sub.

Any help greatly appreciated.



Code:
--------------------

'''Class:
Private Entries As Collection
Private mAcctNo As String
Private mDebit As Integer
Private mCredit As Integer

Public Sub Main(data As Variant)
Dim i As Integer

For i = 1 To data.Length
AddEntry data(1)
Next i
End Sub
Private Sub AddEntry(entry As Variant)
Dim Je As JournalEntry
Set Je = New JournalEntry
Je.acctNo entry(1)
Je.Debit = entry(2)
Je.Credit = entry(3)
Entries.Add (Je)
End Sub
Public Property Let acctNo(val As String)
mAcctNo = val
End Property
Public Property Let Credit(val As Integer)
mCredit = val
End Property
Public Property Let Debit(val As Integer)
mDebit = val
End Property
''------------------------------------------------
''calling code:

Sub getstuff()
Dim vMatrix As Variant
Dim rngLastRow As Range

'a handle on the range we are working with
With ActiveSheet.Range("A:C")

'get the LastRow
Set rngLastRow = .Find(what:="*", searchorder:=xlByRows, searchdirection:=xlPrevious)

'if the range contains data then populate our variant array
If Not rngLastRow Is Nothing Then
vMatrix = .Resize(rngLastRow.Row - .Row + 1, .Columns.Count)
End If

End With
Dim Je As JournalEntry
Set Je = New JournalEntry
Je.Main (vMatrix)

End Sub

--------------------
You would be better of posting all of your code (don't forget to

highlight it after posting and click the # at the top of your reply
window) as i don't see a decleration for data, also you use "AddEntry
data(1)" but it should be "AddEntry data(i)", you must also remember
that unless a Private sub is located within the same module as the one
calling it, it won't be available to the calling sub.


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=98254

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Class programming - how to return chartobject from a class? [email protected] Excel Programming 3 October 11th 06 12:07 PM
Class modules: parametrize class object fields Jean-Pierre Bidon Excel Programming 11 August 31st 06 02:49 PM
Hyperlinks Inserted in Design Mode inactive once Exited Design Mod Craig Excel Programming 0 March 16th 05 04:53 PM
VBA Matrix class R Avery Excel Programming 12 August 11th 04 05:41 AM
Enter Excel Design Mode and Exit Design Mode Bill Lunney Excel Programming 0 August 4th 03 07:48 AM


All times are GMT +1. The time now is 09:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"