home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1996 August / pcpro0796.iso / Code / Dbase next >
Encoding:
Text File  |  1996-06-07  |  823 b   |  27 lines

  1. Code
  2. 1.     Visual Basic/Access Basic - nothing special needs to be done to pass the parameter by reference, because this is the default in Visual Basic and Access.
  3. Dim MyVar As Integer
  4. MyVar = 1
  5. Inc MyVar
  6. MsgBox "Value now " & MyVar, 64, "Increment"
  7.  
  8. Sub Inc(IncRef As Variant)
  9.      IncRef = IncRef + 1
  10. End Sub
  11.  
  12. 2.     FoxPro: the SET UDFPARMS command dictates whether parameters are passed by value or reference by default. The cleanest way by far is to set it to default to passing by value, and then explicitly pass by reference by prefixing with an at sign (@). This code is for Visual FoxPro.
  13. Local lnMyVar
  14.  
  15. Set UDFParms To Value
  16.  
  17. lnMyVar = 1
  18. = Increment(@lnMyVar)
  19. = MessageBox("Value now " + AllTrim(Str(lnMyVar)), 64, "Increment")
  20. Return
  21.  
  22. Procedure Increment
  23.     LParameters tnIncRef
  24.     tnIncRef = tnIncRef + 1
  25. EndProc
  26.  
  27.