CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Guest

    Passing function parameters by reference

    Hi.

    I have a routine that has the following declaration:

    Private Function ParseRec(szStr As String,
    szKey As String,
    szValue As String)

    Within this function, I am modifying the values of szKey and
    szValue by parsing the string szStr.

    I am using the above function as follows:

    ParseRec(szSearch, rcRec.Key, rcRec.Value)

    where rcRec is a record with Key and Value fields, both public, of type
    String.

    I am doing a trace of this within the function ParseRec, and
    see that both Key and Value are being updated, but outside the
    function, the rcRec.Key and rcRec.Value fields do not get
    updated. What am I doing wrong ?

    Any information will be greatly appreciated.

    Thank you.
    Raja




  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Passing function parameters by reference

    your statement:
    ParseRec(...)
    passes arguments by value
    2 ways to solve it:
    Call ParseRec(...)
    or
    ParseRec ... ' arguments without parenthesis!



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