Global Variables and Events

G

Guest

I have a global variable that I set in one procedure that is called from one
event. There are also some events such as getfocus, lostfocus, etc. that are
triggered for another control that get stacked up that apparently are
executed after my procedures exits. The new Global variable value that gets
set in this procedure is not recognized by the events that execute after my
procedure exits. Instead the old value of the Global Variable is used. I
have tried Application.DoEvents all over the place and it doesn't seem to
help. Does anyone else have this problem?

The particulair event that I call the procedure from is a TextBox Validating
event and the variable is used in the next control that gets the focus.

I know this isn't very clear but if anyone knows what I'm trying to
describe, please let me know that I'm not the only one having this problem
and hopefully, a solution.
 
C

Cor Ligthert

Dennis,

Is this accoording to your previous question about the sequence of the
events?

Cor
 
G

Guest

Not really. It's just that the value of a global variable that I set in one
event is not used in a cascading event...the old value of the global
variable is used. It's hard to track what is happening because when I put a
break point in, the value reported is the new value but yet when I set a
temporary variable = the global variable in the event then do a break, the
old value was assigned to the global is reported in the temporary variable
and the global variable shows the new value . I was just wondering if
someone has had a similiar problem and if they were able to resolve it.
 
C

Cor Ligthert

Dennis,

When it was I could have had a look in that code, can you sent us a little
sample from such an event?

You have described it very nice, however as I saw yesterday in a problem,
can give a text as "a shared variable is always static". Give
misunderstandings because a "static variable is not always shared". In those
cases can a little code snippet clear a lot.

:)

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top