![]() |
Passing arguments to a sub routine...
I've written some code in Excel and I'm developing the Error Handling
portion of it. I've written a small subroutine that will generate (or append to) an error log so that I can track any errors that I might get. What I've done (and tested) is create the following subroutine ' ' ' Sub ErrLog (strModule as String, intError as Integer, strDesc as String) Dim strOutput as String strOutput = "An error was report from Module - " & strModule & ". The error is " & intError & " " & strDesc Open "C:\ErrorLog.txt" for Append as #1 Write #1, strOutput Close #1 End Sub The variables that I'm passing it are strModule (which is the name of the subroutine that the error occurred) intError (which is the actual error number) strDesc (which is the error's description) I'm using the standard error trapping routine... Sub Proc1( ) On Error GoTo Proc1Error Proc1Error_Exit: Exit Sub Proc1Error: ErrLog ("Proc1", Err.Number, Err.Description) Resume Proc1Error_Exit End Sub I'm getting an error message indicating that it's expecting an "=". If I modify the ErrLog subroutine so that it only accepts the strModule variable and I eliminate the Err.Number and Err.Description from the line that calls ErrLog, everything works as I want it to. Can I not pass Err.Number or Description to another subroutine? Thanks. Jeff |
Passing arguments to a sub routine...
Thanks. I'll be sure to try that tomorrow. Somehow, I think I should have
known that. "Dave Peterson" wrote in message ... Either: Call ErrLog ("Proc1", Err.Number, Err.Description) or ErrLog "Proc1", Err.Number, Err.Description may work ok for you. Jeff Harbin wrote: I've written some code in Excel and I'm developing the Error Handling portion of it. I've written a small subroutine that will generate (or append to) an error log so that I can track any errors that I might get. What I've done (and tested) is create the following subroutine ' ' ' Sub ErrLog (strModule as String, intError as Integer, strDesc as String) Dim strOutput as String strOutput = "An error was report from Module - " & strModule & ". The error is " & intError & " " & strDesc Open "C:\ErrorLog.txt" for Append as #1 Write #1, strOutput Close #1 End Sub The variables that I'm passing it are strModule (which is the name of the subroutine that the error occurred) intError (which is the actual error number) strDesc (which is the error's description) I'm using the standard error trapping routine... Sub Proc1( ) On Error GoTo Proc1Error Proc1Error_Exit: Exit Sub Proc1Error: ErrLog ("Proc1", Err.Number, Err.Description) Resume Proc1Error_Exit End Sub I'm getting an error message indicating that it's expecting an "=". If I modify the ErrLog subroutine so that it only accepts the strModule variable and I eliminate the Err.Number and Err.Description from the line that calls ErrLog, everything works as I want it to. Can I not pass Err.Number or Description to another subroutine? Thanks. Jeff -- Dave Peterson |
All times are GMT +1. The time now is 10:37 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com