IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
To/From Code
-Collapse +Expand Cross Ref Guide
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesVB.Net  Print This     

Self Keyword (VB.Net and ASP Classic Cross Reference Guide)

By Mike Prestwood

VB.Net versus ASP Classic: A side by side comparison between VB.Net and ASP Classic.

 
Language Details
 

Language Details is kind of a catch all for stuff that didn't make it into language basics nor any other category.

Self Keyword

[Other Languages] 
VB.Net:   Me

To refer to the current instance of a class or structure, use the Me keyword. Me provides a way to refer to the specific instance in which the code is currently executing. It is particularly useful for passing information about the currently executing instance.

The Me keyword is also used as a modifier of the first parameter of an extension method.

You cannot use Me with static method functions because static methods do not belong to an object instance. If you try, you'll get an error.

Syntax Example:  
Sub SetBackgroundColor(FormName As Form)
  //FormName.BackColor = ...some color
End Sub
  
//Pass Me.
SetBackgroundColor(Me)
ASP Classic:   me

Same as VB. The Me keyword is a built-in variable that refers to the class where the code is executing.

Syntax Example:
Class Cyborg
 Public CyborgName
 
 Public Function IntroduceYourself() 
  'Using Me. Prints Cameron.
  Response.Write("Hi, my name is " & Me.CyborgName & ".")
  
  'The above is just a demo. You could also not include "Me." 
  'in this case because we are in context of Me now. Using Me 
  'makes more sense when you start to pass Me as a parameter 
  'to a method.
 End Function 
End Class












Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2024 Prestwood IT Solutions.   [Security & Privacy]