Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do you use the object "me"? 5

Status
Not open for further replies.

duckyboyz

Programmer
Mar 28, 2002
57
US
how and what does the object "me" do?
 
I don't think VBScript has a me object. Are you perhaps asking about me in VBA?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Me is a special "object pointer" much like "this" in JScript/JavaScript. It only exists in the context of IE as far as I know.

Example:
Code:
<html>
  <head>
    <script language="VBScript">
      Sub btnclick
        Me.value = "Clicked!"
      End Sub

      Sub window_onload
        Dim i, objBtn

        For i = 1 To 4
          Set objBtn = document.createElement("input")
          objBtn.type = "button"
          objBtn.value = "Button " & CStr(i)
          Set objBtn.onclick = GetRef("btnClick")
          document.body.appendChild objBtn
        Next
        Set objBtn = Nothing
      End Sub
    </script>
  </head>
  <body>
  </body>
</html>
After the onload event handler finishes, we have a series of elements with their onclick handlers set to the subroutine btnClick. Within the event handler, Me references the source of the event that triggers it.
 
Hello all,

Further to dilettante's excellent demo, here is the me outside of ie context.
Code:
filespec=wscript.scriptfullname
me.searchit filespec

sub searchit(fspec)
	wscript.echo fspec
end sub
regards - tsuji
 
I can also be used within a class to access the class's properties etc
 
Hello mrmovie,

Sure it can. It is a self referential of an object or a class.

regards - tsuji
 
I knew about me in the context of IE, but I never knew about the self referential class aspects. Stars all around.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Yep, an excellent catch. I had completely forgotten Me in the context of a VBScript Class.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top