#1
  1. No Profile Picture
    Dissident
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Mar 2003
    Location
    New York
    Posts
    1,671
    Rep Power
    49

    Vbscript equivilent to javascript's "this" ?


    been a while since I used VBscript and I can't remember (or find online or on this forum) the keyword to self reference an object.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    138
    Rep Power
    12
    The question is why do you want one. I don't think there is one.

    What do you want to use it for?

    If you want to test equivelence between "this" and another object inside an object you can pass a reference to your object to itself.

    Code:
    <%
    Set x = new myObj
    Set y = new myObj
    
    response.write x.compare(x,y) ' should be False
    response.write x.compare(x,x) ' should be True
    
    Class myObj
      Public Function compare(a,b)
          compare = (a Is b)
      End Function
    End Class
    %>
    --

    ngibsonau
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    1
    Rep Power
    0

    Talking Vbscript equivilent to javascript's "this" is "me" !


    after "hours" of google searches, I found something...
    the key word looks to be "me"
    for example :

    assume oBar is another object to witch you whant to add the new object that you are creating using the addChild method of oBar that request the reference of the object to add
    Code:
    '=====CODE=====
    Class foo
      'constructor
      Private Sub Class_Initialize
        oBar.addChild(me)
      End Sub
    End Class
    '=====END OF CODE=====
    notice that accessing "me" seems to refer to the object as if we where outside the class. So the following WON'T work:
    Code:
    '=====CODE=====
    Class foo
      'private property
      Private propertyName
    
      'constructor
      Private Sub Class_Initialize
        propertyName = "Foo"
        response.write(me.propertyName)
      End Sub
    End Class
    '=====END OF CODE=====
    So you'll have to do create a public getter for this property, as following :
    Code:
    '=====CODE=====
    Class foo
      'private property
      Private propertyName
    
      'Getter
      Public Property Get myProperty
        myProperty= propertyName
      End Property
    
      'constructor
      Private Sub Class_Initialize
        propertyName = "Foo"
        response.write(me.myProperty)
      End Sub
    End Class
    '=====END OF CODE=====
    I know this tip is probably too late for
    draelon, I'm sorry.

IMN logo majestic logo threadwatch logo seochat tools logo