Solved

passing an argument into the class initialisation function

Posted on 2003-11-20
5
172 Views
Last Modified: 2010-05-03
I have create a class module ("style")

in the class I have used the initialise function, I want this function to accept a 'string' as an argument.

ie private sub initialize(textBlock as string)



However when I try to create this class, I do not know how to pass the string to the class, I would have thought it would be as follows:

dim tS as style
set tS = new style(myString)

However this produces an error.

Could someone please enlighten me as to how this works.

Thanks,
Cassandra


0
Comment
Question by:calebS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
dancebert earned 45 total points
ID: 9790593
Which version of VB?  You can't do this in VB6 or earlier.
0
 
LVL 1

Author Comment

by:calebS
ID: 9790865
Yes, it is VB6.

So is there anyway I can get around this?

The only way I can think of would be to create a public 'onInitialise' class:
ie public function onInitialise(textBlock)



then to create the class I could do the following:

dim tS as style
set tS = new style
tS.onInitialise(textBlock)

It would of course leave room for error (I could forget to call the onInitialise class), it wouldn't be too hard to put a switch in it so that it could only ever be called once.

Is this my only option?





0
 
LVL 7

Assisted Solution

by:Z_Beeblebrox
Z_Beeblebrox earned 45 total points
ID: 9790930
Unfortunately, yes, that is your only option. You probably want to put a check in all of your other functions to make sure that your onInitialize function has been called and throw an error if it hasn't to minimize the chance of errors.

Or, you could switch to VB.Net.... :)

Zaphod.
0
 
LVL 1

Author Comment

by:calebS
ID: 9790949
I thought about switching, but this little project is on a tight time frame, and I want to switch to C# when I do. So I will finish it first, then spend a month or two making the change.

thanks for your help
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question