Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default what can classmodules do

Hi,

I am programming slotmachine-algorythms in excel to find a way to become
rich without working.

I know how to create a user interface, to create modules and connecting
subroutines, to create functions. However, I keep stumbling on the fact that
when I have created a subroutine for one programme and want to use this for
a next programme, I need to copy and paste the routine.

Is there a way out of this?

When I look at the helpdescription of classmodules I figure this could be of
some help, but when I'm in such a classmodule I don't know what to do.


Any help is greatly appreciated,

greets,

Sybolt


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default what can classmodules do

you'll still have to copy a class module from one project to another..
Stick to modules.

A class module pretty much codes the same as a regular module, but using it
is WAY different.

you use a class to define something you're going to make more and more of.

For an example (programmers, realize I'm simplifying the description here).

A worksheet is an example of a class.

you can write

dim X as worksheet

set X = new worksheet

then use X as if it were a variable.

In your program try this in a class module


Name it myclass

put this code in it

public X as long
public Y as long




then in a code module write this

dim FirstTest as myclass
dim SecondTest as myclass

set firstTest = new myclass
set secondTest = new myclass

firstTest.x = 5
SecondTest.x = 10

debug.print "first " & firstTest.x
debug.print "second " & secondtest.x






"sybmathics" wrote:

Hi,

I am programming slotmachine-algorythms in excel to find a way to become
rich without working.

I know how to create a user interface, to create modules and connecting
subroutines, to create functions. However, I keep stumbling on the fact that
when I have created a subroutine for one programme and want to use this for
a next programme, I need to copy and paste the routine.

Is there a way out of this?

When I look at the helpdescription of classmodules I figure this could be of
some help, but when I'm in such a classmodule I don't know what to do.


Any help is greatly appreciated,

greets,

Sybolt



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default what can classmodules do

A class module won't necessarily help, and doesn't seem terribly
well suited to your application. Instead, put all your common
procedures in a workbook. Then, in the VBA Editor, go to the
Tools menu, choose VBA Project Properties, and change the name of
the project to something meaningful. Finally, in the workbooks
that need to use the procedures, in VBA go to the Tools menu,
choose References, and check the reference to the project
containing your common routines.


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


"sybmathics" wrote in message
l...
Hi,

I am programming slotmachine-algorythms in excel to find a way
to become rich without working.

I know how to create a user interface, to create modules and
connecting subroutines, to create functions. However, I keep
stumbling on the fact that when I have created a subroutine for
one programme and want to use this for a next programme, I need
to copy and paste the routine.

Is there a way out of this?

When I look at the helpdescription of classmodules I figure
this could be of some help, but when I'm in such a classmodule
I don't know what to do.


Any help is greatly appreciated,

greets,

Sybolt



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default what can classmodules do


"TomHinkle" wrote in message
...
A worksheet is an example of a class.

you can write

dim X as worksheet

set X = new worksheet


Just give that a try, and see if you can!


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default what can classmodules do

I am not convinced that a class module is what you need here. They are handy
in some situations such as events but judging by your question that is not
the case here. For many of my common utility type functions and procedures I
create modules and give them meaningful names. A module can be exported
(right click the module and you will see export as an option). For your next
project that needs that functionallity just right click the project and
select import. I have modules for creating toolbars, error handling, string
manipulations, ADO Connections, Network Connections... any of which I can
just plug into a new project to get the functionality I want. Similar(ish) to
C programming where you add a header file.
--
HTH...

Jim Thomlinson


"sybmathics" wrote:

Hi,

I am programming slotmachine-algorythms in excel to find a way to become
rich without working.

I know how to create a user interface, to create modules and connecting
subroutines, to create functions. However, I keep stumbling on the fact that
when I have created a subroutine for one programme and want to use this for
a next programme, I need to copy and paste the routine.

Is there a way out of this?

When I look at the helpdescription of classmodules I figure this could be of
some help, but when I'm in such a classmodule I don't know what to do.


Any help is greatly appreciated,

greets,

Sybolt





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default what can classmodules do

Read the whole thread...

"For an example (programmers, realize I'm simplifying the description here)."

I used worksheet because I figured it would be something someone could
relate to..

If you read the WHOLE post you'd realize I was trying to describe a class in
a short amount of space.

Sorry if you don't get it.

"Bob Phillips" wrote:


"TomHinkle" wrote in message
...
A worksheet is an example of a class.

you can write

dim X as worksheet

set X = new worksheet


Just give that a try, and see if you can!



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default what can classmodules do


"TomHinkle" wrote in message
...
Read the whole thread...

"For an example (programmers, realize I'm simplifying the description

here)."

Simplifying and giving wrong information are poles apart.

I used worksheet because I figured it would be something someone could
relate to..


But what you are saying is wrong,. So that invalidates everything you said.

If you read the WHOLE post you'd realize I was trying to describe a class

in
a short amount of space.


If you can't explain correctly, it is best not to give erroneous
information.

Sorry if you don't get it.


Who doesn't get it?


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default what can classmodules do

Instead of trying to be cute, why don't you just expand on answers that you
feel are incomplete with your knowledge.. maybe some of us could learn
something..

"Bob Phillips" wrote:


"TomHinkle" wrote in message
...
A worksheet is an example of a class.

you can write

dim X as worksheet

set X = new worksheet


Just give that a try, and see if you can!



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default what can classmodules do

I don't think it is necessary to use class modules in this case as others
have said. Explaining class modules is difficult (as Jamie Collins says,
class modules is something that you don't get until you get it). I know how
hard it is and am compiling a paper on the subject at the moment, so I
certainly wouldn't try to explain it in a NG response, especially when the
OP doesn't need it.

But giving wrong information should be challenged, it isn't being cute, it
is trying to stop misleading information.

Bob

"TomHinkle" wrote in message
...
Instead of trying to be cute, why don't you just expand on answers that

you
feel are incomplete with your knowledge.. maybe some of us could learn
something..

"Bob Phillips" wrote:


"TomHinkle" wrote in message
...
A worksheet is an example of a class.

you can write

dim X as worksheet

set X = new worksheet


Just give that a try, and see if you can!





  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default what can classmodules do

On Tue, 14 Jun 2005 at 20:14:49, sybmathics (sybmathics
) wrote:
However, I keep stumbling on the fact that
when I have created a subroutine for one programme and want to use this for
a next programme, I need to copy and paste the routine.

I just save my module as an XLA file for my common routines
--
Mike


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default what can classmodules do

That works great so long as you don't have to distribute the spreadsheet.
Otherwise you have to give the xla along with the spreadsheet... That being
said everyone in my department has one of my xla's installed and so it works
great.
--
HTH...

Jim Thomlinson


"Mike NG" wrote:

On Tue, 14 Jun 2005 at 20:14:49, sybmathics (sybmathics
) wrote:
However, I keep stumbling on the fact that
when I have created a subroutine for one programme and want to use this for
a next programme, I need to copy and paste the routine.

I just save my module as an XLA file for my common routines
--
Mike

  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default what can classmodules do


or until you get it instantiated :)

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Bob Phillips wrote :

as Jamie Collins says,
class modules is something that you don't get until you get it

  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default what can classmodules do

Can I get a copy of the paper when you are done? I "get it" and I would still
love to get a copy.

P.S. Tom if you find a response to a solution you post to be impolite or
disrespectful, I can assure you that it is never meant that way. Bob is one
of the best coders on the forum and I am sure no disrepect was intended. He
called you on a mistake which we all have made. When a mistake is posted I
can assure you the error will be pointed out.
--
HTH...

Jim Thomlinson


"Bob Phillips" wrote:

I don't think it is necessary to use class modules in this case as others
have said. Explaining class modules is difficult (as Jamie Collins says,
class modules is something that you don't get until you get it). I know how
hard it is and am compiling a paper on the subject at the moment, so I
certainly wouldn't try to explain it in a NG response, especially when the
OP doesn't need it.

But giving wrong information should be challenged, it isn't being cute, it
is trying to stop misleading information.

Bob

"TomHinkle" wrote in message
...
Instead of trying to be cute, why don't you just expand on answers that

you
feel are incomplete with your knowledge.. maybe some of us could learn
something..

"Bob Phillips" wrote:


"TomHinkle" wrote in message
...
A worksheet is an example of a class.

you can write

dim X as worksheet

set X = new worksheet

Just give that a try, and see if you can!






  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default what can classmodules do


"Jim Thomlinson" wrote in message
...
Can I get a copy of the paper when you are done? I "get it" and I would

still
love to get a copy.


Of course Jim, when it is ready it will be posted in the public domain
anyway. If you are that keen, perhaps you would be willing to do a peer
review on it for me. Perhaps we can have an offline email exchange on it.

Regards

Bob


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
How to keep values in classmodules Gottfried Ehmann Excel Programming 2 August 5th 03 08:39 AM


All times are GMT +1. The time now is 07:38 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"