CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2001
    Posts
    3

    Function or Procedure

    What are the factors to be considered to write a method as Procedure or function?


  2. #2
    Join Date
    Dec 2000
    Location
    Colombo,Srilanka
    Posts
    50

    Re: Function or Procedure

    function has return value.
    so if U want to return a value after the process u can use a function

    Dinesh Asanka

  3. #3
    Join Date
    May 2001
    Posts
    3

    Re: Function or Procedure

    Yes, of course, Function has return value. but i can return this value as out parameter through a procedure also.




  4. #4
    Join Date
    Dec 2000
    Location
    Colombo,Srilanka
    Posts
    50

    Re: Function or Procedure

    if UR using procedure


    call ProcedureName(parameters)
    if returnvalue = true then

    endif




    if UR using Function


    if FunctionName(parameters) = true then

    endif




    Dinesh Asanka

  5. #5
    Join Date
    May 2001
    Posts
    3

    Re: Function or Procedure

    Thanks..

    This infers that
    It is most appropriate to use a function when the return value is used in expressions, as procedures cannot be used in expressions




  6. #6
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Function or Procedure

    ...and it is not a good practice to use variable (public or global) to the purpouse of return a value from a sub: you will be in a mess while trying to keep track of all public/global variables as soon as your project grows; moreover, public/global may be used by mistake somewhere else, where they should not...

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured