Re: How to refer to a class property while in that class. (Solved)
- From: "Dan" <danncasey@xxxxxxxxx>
- Date: 1 May 2006 22:33:47 -0700
Progress, but still confused.
I've read that i can set the variable by using me.myproperty = "value".
However when I try to do this it does not work. Here is the relevent
code.
class dataProc
Private m_token
Public Property Get Token()
Token = m_token
End Property
Private Property Let Token(p_data)
m_token = p_data
session("token") = p_data
End Property
Public Function makeToken()
' Generates a token. Stores it in the Token Property of this class
Dim i
Dim tmpToken
Dim randnum
Dim Values
Vals =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-()!#,[]"
Randomize
For i = 1 to 20
randnum = int(rnd*len(Vals)) +1
tmpToken = tmpToken & mid(Vals,randnum,1)
Next
Me.Token = tmpToken
makeToken = true
End Function
The line that says "me.Token" used to say "m_token", which worked fine.
But I'm just testing in this function to try out a reference to the
class. So when I use Me.Token (like above), I get the following error:
Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'Me.Token'
-------------------------------
Actually I just solved this. I'll through the post up anyway for others
(or myself in a few hours) run into the same problem.
The Let property for Token was declared as private rather then public.
I did this because I only wanted to change this from within the class.
I guess when you refer to it as an instace (like "me") your in a
different scope.
.
- Follow-Ups:
- References:
- Prev by Date: Help on deletion of Registrykey with subkeys under it using vbscript
- Next by Date: Re: How to refer to a class property while in that class. (Solved)
- Previous by thread: How to refer to a class property while in that class.
- Next by thread: Re: How to refer to a class property while in that class. (Solved)
- Index(es):
Relevant Pages
|