ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   referencing at module level (https://www.excelbanter.com/excel-programming/293037-referencing-module-level.html)

Mark[_36_]

referencing at module level
 
Hi NG

I have a small problem with referencing a public variable in a module

Module A:
public strXML as string

Module B:
sub something
msgbox "String: " & A.strXML
end sub

My problem is that the first time a run the above everything works fine, but
the second time i run it then strXML = "". Like it has been flushed somehow.
I tried it with other objects too, and the same accured.

Does anyone know what is going on and how to fix it?

Mark



Jan Karel Pieterse

referencing at module level
 
Hi Mark,

Module A:
public strXML as string

Module B:
sub something
msgbox "String: " & A.strXML
end sub

My problem is that the first time a run the above everything works fine, but
the second time i run it then strXML = "". Like it has been flushed somehow.
I tried it with other objects too, and the same accured.


Does your code contain any End statement?

Also, AFAIK you don't need the A. prefix before the variable name. Unless
another module also contains a variable by that name, which makes declaring
that variable as public illogical in the first place.

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com



All times are GMT +1. The time now is 03:23 AM.

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