Information générale
Catégorie:
Codage, syntaxe et commandes
Titre:
How to pass parms to custoom classes?
I'm new to the whole visual realm so this may be a rather stupid question; however, its enough to give me a headache.
I'm trying to create a custom class. I want to be able to pass a parameter to it as it's being initialized. I've done the following but I keep getting the error: Function argument value, type, or count invalid.
(Using VFP 7)
***** Class definition in c:\temp\test.prg
define class TstClass as custom
protected tstValue
function Init(cType as string)
= messagebox(cType)
this.tstValue = cType
endfunc
enddefine
***** command line code
oTest = newobject("TstClass","c:\temp\test.prg",,"Value")
Running the above line is when I get my error. The error message hits before the messagebox ever displays. I've even removed the messagebox just to make sure that the error wasn't happening there.
From everything I've read, that should be right. Am I forgetting something? Can you not pass parameters to the Init function? (Everything I've read says you can.)
Thanks for whatever help you can offer!
Rodd
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement