Another question for Bill Wilkinson

Results 1 to 2 of 2

Thread: Another question for Bill Wilkinson

  1. #1
    Innana Guest

    Default Another question for Bill Wilkinson

    Thanks for the help with my last question on identifying and replacing characters before storing in the database. I found your advice about putting the char() into a variable to prevent heavy function usage especially interesting and have therefore adjusted my code. <BR><BR>I wonder if you could comment on something that this issue brought to mind:<BR>I know that one of the differences between calling a SUBroutine and a FUNCTIONroutine is that the FUNCTIONroutine returns a value (hope thats right :)) but if you can achieve the desired result by using either which is it best to use?<BR><BR>I am asking because with the character replacement routine we were talking of earlier it seems to work the same with using...<BR><BR> charactertrap strNewsItem to a SUBroutine<BR>or<BR> charactertrap (strNewsItem) to a FUNCTIONroutine<BR><BR>so I was wondering if there is a usage or other reason to use one or the other.

  2. #2
    Join Date
    Dec 1969

    Default A 'probably' answer...

    If you use a SUB, then if you want the string to come *back* to you properly altered, you must pass it BYREF.<BR><BR>That is:<BR><BR>Sub ChangeQuotes( ByRef str )<BR>&nbsp; &nbsp; str = Replace( str, SQT, DBLSQT )<BR>End Sub<BR><BR>With a function, you would normally pass the string ByVal (the default:<BR><BR>Function ChangeQuotes( ByVal str )<BR>&nbsp; &nbsp; ChangeQuotes = Replace( str, SQT, DBLSQT )<BR>End Function<BR><BR>Which is more efficient, IN THIS CASE? I&#039;d say the Sub, but by a very small margin.

Posting Permissions

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