Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

defining an object

Status
Not open for further replies.

rgandy

Technical User
Nov 17, 2005
38
US
if i want to create a simple object with the followuing properties:

obj.text1 = "Single"
obj.value1= .01
obj.value2 = 10

how would i go about doing this? (where obj could be any name and i could create an infinite number of custom characteristics

thanks!
 
I would suggest reading up on Classes.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Huh?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
im booing your answer
i have tried locating this info in the book i have (walkenbach). but it is not helpful enough

if i can get a bit of help starting out im sure i can figure it out it doesnt seem too tough, but i just need to know how to assign the properties and then be able to access them from sub routines
 
Go to Google and enter "vba class module" for the search term. The first hit for me was


which shows how to make a class module aka a custom object.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
rgandy - Uh....I do not think boo-ing someone's answer is very appropriate. You asked a question about creating a custom object. You got an answer. You create custom object using Classes. That is the answer. If you do not like the answer, well that is just tough for you.

Maybe what you have in your book is not informative enough because you are not ready, or informed yourself, to do the work.

As EBGreen suggests, try googling. There are many, many sources, with examples, of creating simple class modules. I certainly did not have to go far to find some. And...if you actually tried some samples...yeah, maybe, you might have some problems. If so, then post here with specific code and specific questions. Have you actually tried to make one? If so, post your code, and tell us what is not working. We will be glad to help out.
rgandy said:
i can figure it out it doesnt seem too tough
Ok....if you have enough of a handle on it to think it is not too tough, then why are you asking generalized questions? Make one, even a simple one like you gave in your original post. If you have specific problems, ask.

But in the meantime....here is a boooooo for your response. Or perhaps a Bronx cheer.

Just as an aside. I did a google. Found a site, not too far down, with a very simple example. Three properties, just like your example. Different value types - you have a string (obj.text1), a double (obj.value1), and what the hech, another double (obj.value2).

I took the stuff from the site, copied it into a VBA project, replaced the names with YOUR names (text1, value1, value2 - which are not very good names BTW), and had the object useable in Subs in less than 10 minutes.

You're right...it is not too tough. Try it.

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top