Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21222

Updating "global" variable from subroutine?

$
0
0
Hi

I have bumped into an annoying problem, when using ILocateCommandEvents (VBA microstation).
What I am trying to do is: Have the user choose a LineElement from the Microstation drawing (this happens in a subroutine in a class module, so I cannot just pass the LineElement as a result, since it is not a function but a subroutine). This LineElement has to be written to a LineElement-variable with a global scope, because I have to use it in another subroutine.

It does not seem to work though. What I have tried is:

1. Declare the LineElement with widest scope possible, in my Module (not class module): Public Element1 as LineElement
2. Then, in my subroutine A, where the user specifies a LineElement (called Element), I write Element1 = Element

However, when I need to use this global Element1 in my subroutine B, it seems like I cannot access it or its value.

Am I doing anything wrong, or is it simply not possible to do what I want to do? I cannot change the subroutines to functions, as they're Microstation built-in routines.

Best regards

Viewing all articles
Browse latest Browse all 21222

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>