Re: How to refer to a class property while in that class. (Solved)

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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.

.



Relevant Pages

  • Re: Problem with execution order in print routine
    ... Private Const DM_ORIENTATION = &H1 ... Dim strPrinterDesignation As String ... Dim iRet As Long ... "Unexpectedly could not access printer property ...
    (microsoft.public.word.vba.general)
  • Re: API upgrade problem - VB6 to VB.NET
    ... Private Const mcCaseInsensitive As Long = &H40 ... (ByRef pSection As Long, ByVal pAccess As Long, ByRef pObjAttribs As ... : Private Sub GetSerialParallel() ... Dim vMemoryAs Byte ...
    (microsoft.public.vb.winapi)
  • Re: Communicating between Applications
    ... Private Declare Function CloseHandle _ ... Const SUBLANG_DEFAULT = &H1 ... Private Sub Command1_Click ... Dim BytesWritten As Long ...
    (microsoft.public.vb.general.discussion)
  • Re: AlphaBlending Transparent PNG Files
    ... I'm assuming I need to call the private CreateDIB() to create a DIB, ... Dim lngHeight As Long, lngWidth As Long ... Private Declare Function AlphaBlend Lib "MSImg32.dll" (ByVal hDCDest As ... Private Type Bitmap ' 24 bytes ...
    (microsoft.public.vb.winapi.graphics)
  • NtOpenSection - how to use in .NET??
    ... Private Const mcCaseInsensitive As Long = &H40 ... (ByRef pSection As Long, ByVal pAccess As Long, ByRef pObjAttribs As ... Private Sub GetSerialParallel() ... Dim vMemoryAs Byte ...
    (microsoft.public.dotnet.framework.interop)