I.T. Discussion Community!
-Collapse +Expand

To/From Code

-Collapse +Expand Languages
-Collapse +Expand Categories
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesOOP Basics    Print This   

Member Method (Cross Ref > OOP Basics)

Member Method

Also known as a Class Method.

A code routine that belongs to the class or an object instance (an instance of the class). Methods that belong to the class are called class methods or static methods. Methods that belong to an object instance are called instance methods, or simply methods.

When a method returns a value, it is a function method. When no value is returned (or void), it is a procedure method.

Methods frequently use method parameters to transfer data. When one object instance calls another object instance using a method with parameters, you call that messaging.

Access VBA:   Sub, Function

Access VBA uses the keywords sub and function. A sub does not return a value and a function does. Many programmers like to use the optional call keyword when calling a sub to indicate the call is to a procedure.

More Info / Comment
ASP Classic:   Sub, Function

ASP classic uses the keywords sub and function. A sub does not return a value and a function does. Many programmers like to use the optional call keyword when calling a sub to indicate the call is to a procedure.

Syntax Example:
'Declare class.
Class Cyborg
  Public Function IntroduceYourself() 
    Response.Write("Hi, I do not have a name yet.") 
  End Function 
End Class
 
'Create object from class.
Set T1 = new Cyborg
T1.IntroduceYourself() 
C#: 

In C#, you indicate a method with parens, no parens indicates a member property. Use the void return type for methods that do not return a value.

Syntax Example:

Define class:

public class Cyborg : System.Object
{
public virtual void IntroduceYourself()
{
MessageBox.Show("Hi, I do not have a name yet.");
}
}

Create object from class:

Cyborg T1 = new Cyborg();
T1.IntroduceYourself();
Delphi:   procedure, function

Delphi uses the keywords procedure and function. A procedure does not return a value and a function does.

Syntax Example:
//Interface section:
TCyborg = class(TObject)
public
  procedure IntroduceYourself;
end;
 
//Implementation section;
procedure TCyborg.IntroduceYourself;
begin
  ShowMessage('Hi, I do not have a name yet.');
end;
 
//Some event like a button click:
var
  T1: TCyborg;
begin
  T1 := T1.Create;
  T1.IntroduceYourself;
end;
Delphi Prism:   method, procedure, function

Prism uses the keyword method for member methods and is the preferred syntax over the legacy procedure and function keywords. Although method is preferred, you can use procedure or function if you want the compiler to make sure all functions return a value and all procedures do not.

Syntax Example:

In the interface section:

Cyborg = class(System.Object)
  public method IntroduceYourself();
end;

In the Implementation section:

method Cyborg.IntroduceYourself();
begin
  MessageBox.Show("Hi, I do not have a name yet.");
end;
 

On some event like a button click:

var T1: Cyborg;
begin
  T1 := New Cyborg;
  T1.IntroduceYourself;
end;
JavaScript: 

Not fully OOP as you can call the method outside of the class.

Syntax Example:
function Dog() {
  //Class variables here.

this.prototype.bark = function() {
//Class method code here.
}
}
ObjectPAL:   Not Supported
VB Classic:   sub, function

VB classic uses the keywords sub and function. A sub does not return a value and a function does. Many programmers like to use the optional call keyword when calling a sub to indicate the call is to a procedure.

More Info / Comment
VB.Net:   Sub, Function

VB.Net�uses the keywords sub and function. A sub does not return a value and a function does. Many programmers like to use the optional call keyword when calling a sub to indicate the call is to a procedure.

Syntax Example:

Class definition:

Public Class Cyborg
� Inherits Object
 
Public Sub IntroduceYourself()
��� MessageBox.Show("Hi, I do not have a name yet.")
� End Sub
End Class

Some event like a button click:

Dim T1 As New Cyborg
T1.IntroduceYourself()




1,377 People Online Now!!  
Online Now: 1373 Guests, 4 Members: Batgirl  chris.h2  Jose Brinkmann  Jozsef.P  
Online Today: 5 Members: Batgirl  chris.h2=Analyst  Jose Brinkmann=Owner  Jozsef.P=Coder  Park.G=Tester  
Most Online:  Today=1,466@1:05AM PST,  Last 7 Days=2,021 on 2/6/2012,  30 Days=3,627 on 1/29/2012,  Year=7,733 on 12/13/2011,  Ever=48,902 on 9/20/2008.
Website Sessions! (Server cycled 179 minutes ago.)
Visitor Count:  7,569 visitor sessions in last 3 hours.  (Average=2,523/Hour visiting 4 pages each.)
Current Estimates:  1,843,052 Visitors per month, 7,372,206 Hits per month (full page loads)
12,397 Registered Members!
New Members Last 24 Hours=4,  Week=16,  Month=100,  Year=903
Newest Member :  Park.G (Park Geun Su) Groups= Paradox, Tester
Show More...
Follow PrestwoodBoards on: 


©1995-2012 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech

 
-
 
Have a question? Need our services? Contact us now.
--Mike Prestwood

Call: 916-726-5675

email: info@prestwood.com