Re: How to refer to a class property while in that class. (Solved)
- From: "mayayana" <mayayanaXX1a@xxxxxxxxxxxxxxxx>
- Date: Tue, 02 May 2006 15:56:01 GMT
I tried that out and it does seem to work
like you say:
______________________________
Dim c1
Set c1 = new dataProc
MsgBox c1.Token
c1.DoMe
MsgBox c1.Token
Set c1 = Nothing
Class dataProc
Private m_token
Public Property Get Token()
Token = m_token
End Property
Public Property Let Token(p_data)
m_token = p_data
End Property
Public Sub DoMe()
Me.makeToken
End Sub
Public Function makeToken()
m_token = "blah"
End Function
End Class
______________________________
The second msgbox says "blah", indicating
that Me.makeToken ran OK.
I don't see the point, though. The makeToken
sub is in your scope, so "Me" is superfluous.
I don't know about "Me" in PHP. "Me" is used
in VB to reference a VB Form from within itself
because there needs to be a reference to the
form object. But in a class there's nothing you don't
have access to. Even an event sub like Class_Initialize
is still just a local sub from inside the class, so
there just isn't any purpose for "Me" as far as I
can see. In other words, you don't need to reference
the class object to access any of the class functionality
if you're running inside the class.
You can use simply:
makeToken
To use Me.makeToken is like saying to yourself:
"Self, let's have lunch."
It's obviously "Self" you're referring to. :)
for example, here is another function I'm trying to run in the same
class. (sorry for not putting this in the previous post)
Public Function makeNew()
If Len(Me.Token) <> 20 Then
Me.MakeToken
End If
When this runs, Len(Me.Token) translates to 0, which would leave me to
believe that me.Token is Null because it is not referencing the class
properly.
On the other hand, Me.MakeToken on the next line successfuly runs the
makeToken function.
Note: from the main script I've done the following to ensure that
Token, is not actually null.
Set dp = new dataProc
dp.MakeToken
response.write(dp.Token) ' which has a value or 20 chars
dp.MakeNew
.
- Follow-Ups:
- References:
- How to refer to a class property while in that class.
- From: Dan
- Re: How to refer to a class property while in that class. (Solved)
- From: Dan
- Re: How to refer to a class property while in that class. (Solved)
- From: Dan
- Re: How to refer to a class property while in that class. (Solved)
- From: mayayana
- Re: How to refer to a class property while in that class. (Solved)
- From: Dan
- Re: How to refer to a class property while in that class. (Solved)
- From: Dan
- How to refer to a class property while in that class.
- Prev by Date: Re: Enumerate (count) number of times phrase used in txt document
- Next by Date: Re: Filtering an Array ; what if no matches found ?
- Previous by thread: Re: How to refer to a class property while in that class. (Solved)
- Next by thread: Re: How to refer to a class property while in that class. (Solved)
- Index(es):
Relevant Pages
|