ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Passing a variable to a GoTo (https://www.excelbanter.com/excel-programming/409340-passing-variable-goto.html)

Planner[_3_]

Passing a variable to a GoTo
 
I am trying to pass a public variable between modules to a Goto
statement.

Example
Public Sub Do_a_Lot (Err_Code)
Dim Err_Code As Integer

'When something goes wrong

On Error Resume Next
Err_Code = 1

Call Errorcall(Err_Code)
End Sub

The in a seperate Module I have the Error handling

Public Sub Errorcall(Err_Code)
X=Err_Code
Goto X:

However the macro errors out when trying to initialise the Errorcall
module because whilst compiling it hits the Goto statement with label
X not defined, but it needs to be defined by the Err_code.

Thanks in advance

John

Peter T

Passing a variable to a GoTo
 
Select Case Err_Code

Not sure your use of Goto is the best approach though.

Regards,
Peter T

"Planner" wrote in message
...
I am trying to pass a public variable between modules to a Goto
statement.

Example
Public Sub Do_a_Lot (Err_Code)
Dim Err_Code As Integer

'When something goes wrong

On Error Resume Next
Err_Code = 1

Call Errorcall(Err_Code)
End Sub

The in a seperate Module I have the Error handling

Public Sub Errorcall(Err_Code)
X=Err_Code
Goto X:

However the macro errors out when trying to initialise the Errorcall
module because whilst compiling it hits the Goto statement with label
X not defined, but it needs to be defined by the Err_code.

Thanks in advance

John




Planner[_3_]

Passing a variable to a GoTo
 
On 14 Apr, 19:11, "Peter T" <peter_t@discussions wrote:
Select Case Err_Code

Not sure your use of Goto is the best approach though.

Regards,
Peter T


Thanks Peter - Sorted






"Planner" wrote in message

...



I am trying to pass a public variable between modules to a Goto
statement.


Example
Public Sub Do_a_Lot (Err_Code)
*Dim Err_Code As Integer


* * *'When something goes wrong


On Error Resume Next
Err_Code = 1


Call Errorcall(Err_Code)
End Sub


The in a seperate Module I have the Error handling


Public Sub Errorcall(Err_Code)
X=Err_Code
Goto X:


However the macro errors out when trying to initialise the Errorcall
module because whilst compiling it hits the Goto statement with label
X not defined, but it needs to be defined by the Err_code.


Thanks in advance


John- Hide quoted text -


- Show quoted text -





All times are GMT +1. The time now is 12:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com