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 > What to use for a string enum? Read only class?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-19-09, 15:14
mikezx10 mikezx10 is offline
Registered User
 
Join Date: Oct 2003
Posts: 226
What to use for a string enum? Read only class?

I would like to have a string enum in my class. you cant have a string enum, any suggestions on how to handle this?

maybe a class with read only properties? are there static classes in vba? Types that you dont have to instantiate?
Reply With Quote
  #2 (permalink)  
Old 05-20-09, 03:44
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
No static classes. VBA is not a true OO language - I think classes were only bolted on in version 3 or 4 IIRC. You also can't nest classes, in case you were intending to do that.

How come you want string enums? If there are strings, they are not enumerations by definition.
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #3 (permalink)  
Old 05-20-09, 07:16
mikezx10 mikezx10 is offline
Registered User
 
Join Date: Oct 2003
Posts: 226
Quote:
Originally Posted by pootle flump
No static classes. VBA is not a true OO language - I think classes were only bolted on in version 3 or 4 IIRC. You also can't nest classes, in case you were intending to do that.

How come you want string enums? If there are strings, they are not enumerations by definition.

Basicly i wanted to use for Account#s,, but they will have wild cards and groupings so they may be like:

1000234
100*222
234***8,380339

each of those lines will be a grouping for financial reporting
Reply With Quote
  #4 (permalink)  
Old 05-20-09, 07:24
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
Ok.
Understand I am just trying to get a context on this.

Your account numbers have a meaning, they are like codes? So account numbers starting "234" and ending "8" have something in common?
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #5 (permalink)  
Old 05-20-09, 11:17
mikezx10 mikezx10 is offline
Registered User
 
Join Date: Oct 2003
Posts: 226
you got it wild cards are there but not used so i would do an exact match on a string,

so say I have a entry:

acct# 600276*,607*,605*,606*,601*,602*,603*,6006762209
Debit 100000000
Credit 0

In a work book I will then need to find each the line in each sheet with that acct# (leading to next question, if i cant figure out how to do that )
Reply With Quote
  #6 (permalink)  
Old 05-21-09, 03:40
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
Ok - we've left pure VBA (where I'm fairly strong) and got into Excel (where I'm not). Someone else should be able to pick this up now we know what your problem really is.
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #7 (permalink)  
Old 05-21-09, 06:11
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
Mike,

Can you attach a simple example workbook so we can see all of this in context? This will be possible with formulas (probably array formulas), however a different design might improve things.



Just to pick up on the earlier discussion regarding VBA and OO programming.

VBA supports all of the main OO concepts except for inheritance. However, you will find a general trend (an exception, for example, is when working with userforms) that VBA developers prefer to work with a procedural-driven approach rather than a class-driven approach. This is due to state loss events. A state loss event will reset all static and module level variables, and it will destroy all the custom class objects you have created. I'm not aware of a complete list of state loss causes, but here's a starting point:
http://www.xtremevbtalk.com/showpost...60&postcount=1


Hope that helps...
Reply With Quote
  #8 (permalink)  
Old 05-21-09, 06:21
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
Getting off topic here, but Colin - are you seriously saying that VBA supports polymorphism?
I'm happy to argue Encapsulation too, but it's less black and white.

EDIT - I'd simply say VBA is a procedural language with simple classes bolted on. It was not intended to be an OO language, so saying it isn't is not knocking it, it is simply stating the case.
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.

Last edited by pootle flump; 05-21-09 at 06:24.
Reply With Quote
  #9 (permalink)  
Old 05-21-09, 06:36
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
Hi PF,
Quote:
Getting off topic here, but Colin - are you seriously saying that VBA supports polymorphism?
I'm happy to argue Encapsulation too, but it's less black and white.
I apologise if my post was misleading - VBA does not support true polymorphism; I 'justify' my not excluding it because VBA does support interface polymorphism to a limited extent (obviously no overloading etc..). And abstraction and encapsulation in VBA are both ticked boxes for me.


This thread is a follow on from another one where Mike and I were discussing constructors and overloading in VBA.

Last edited by Colin Legg; 05-21-09 at 07:22.
Reply With Quote
  #10 (permalink)  
Old 05-21-09, 10:02
mikezx10 mikezx10 is offline
Registered User
 
Join Date: Oct 2003
Posts: 226
Ok i will post a wks and all the code.
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