View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default User Defined Type


It appears though that programming with (vba) for excel 2000

and vb.net are
two completely different worlds.


Yes, they are quite different. In VBA, a class module contains
one and only one class, whose name is the name of the module. For
your code, first create a new class module, F4 to bring up the
Properties window, and give it a name of LedgerTransaction. In
that module, put the following code:

Public Items As Collection
Public Index As Long

Private Sub Class_Initialize()
Set Items = New Collection
End Sub




Next, create a second class module, name it BankAccountLedger,
and place the following code in that module:

Public Name As String
Public Transactions As Collection
Public LedgerRange As Range

Private Sub Class_Initialize()
Set Transactions = New Collection
End Sub

Then, in your initialization code in a regular code module,
instantiate the classes with code like

Dim LT As LedgerTransaction
Dim BAL As BankAccountLedger
' other code
Set LT = New LedgerTransaction
Set BAL = New BankAccountLedger


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"WStoreyII" wrote in
message
...
I dont have much programming experience, but the little that i

do know is from visual basic.net. It appears though that
programming with (vba) for excel 2000 and vb.net are two
completely different worlds.

So what i need to know is how to make a class or an object that

i can manipulate in my code

I wish to make a Class that Will Be Called LedgerTransaction
this class will have two member variables
1) Items - which will have a collection of range objects that

contain the range of the particular transaction item
2) Index - which will be the index of the transaction

I will also need a class called BankAccountLedger
Wich will have three Member Variables
1) Name
2) Transactions - Collection of Transactions
3) Range the range of the ledger

now this is a very elementry process in vb.net
and i am sure that it is in vba to.
however i am missing something
i tried a classs module
and a user defined types
and received several different error messages.

If anyone could please help me understand this or send me to a

good tutorial i would be very grateful

WStoreyII