If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > using a matrix

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-19-09, 19:45
mikezx10 mikezx10 is offline
Registered User
 
Join Date: Oct 2003
Posts: 226
using a matrix

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
Reply With Quote
  #2 (permalink)  
Old 05-21-09, 09:49
MikeTheBike MikeTheBike is offline
Registered User
 
Join Date: Apr 2004
Location: Derbyshire, UK
Posts: 714
Hi

I have had a quick look and found a one or to probs (vMatrix is a two dimensioanal array?, and you need a NEW key word in the Entries declaration) for which I have suggested some mod as follows
Class Clode
Code:
Option Explicit

Private Entries As New 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 UBound(data, 1)
        AddEntry i, data
    Next i
End Sub
Private Sub AddEntry(index As Integer, entry As Variant)
    Dim Je As JournalEntry
    Set Je = New JournalEntry
    Je.acctNo = entry(index, 1)
    Je.Debit = entry(index, 2)
    Je.Credit = entry(index, 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
This is all a bit incestuous having a collection of 'Journal' Class objects in the 'Journal' class definition ??
Also, the object properties are Write only (no GET Properties) and the Entries collection isn't visible at all, so how are you going to use them ?

Hope this makes sense and helps!!

MTB
Reply With Quote
  #3 (permalink)  
Old 05-21-09, 10:00
mikezx10 mikezx10 is offline
Registered User
 
Join Date: Oct 2003
Posts: 226
i know it seems weird to have have the collection of objects in it self, I am a little confused on how to design the whole thing, i also made the props read write.

I have most of the stuff done now, and will post every thing so all you guys can have a good laugh and give me some design pointers.


Thanks!
Reply With Quote
  #4 (permalink)  
Old 09-07-09, 10:11
kickJohn kickJohn is offline
SPAMMER
 
Join Date: Aug 2009
Location: US
Posts: 1
Don't hesitate

every dofuser needs dofus kamas, but most of them can't find a good cheap dofus kamas provider, so it's a problem is they want to buy cheap dofus kamas.now bawwgt will be your best choice on dofus
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On