VB6 - Genric globals

Started by
3 comments, last by garyfletcher 15 years, 2 months ago
Hi All When going from form1 to form2 is there a way, without using PUBLIC globals, that functions/Subs in Form2 have to access a project level variable that will indicate the form that the current form was called from? So in a func/sub you could have something like: if (lastform = 'form1') then do processing based on being called from form1; else do some other processing end if Sorry am new to VB programming, but am guessing that this can be done.
Gary.Goodbye, and thanks for all the fish.
Advertisement
My guess would be to have each form contain a public "Caller" variable of type Form. Each time you display a form, you load it first, then set "caller" to the name of the caller form, then call the Show method. The code on each form would have to assume that its Caller variable contains a correct value only after the form has been displayed, and not OnLoad. There's been a while since I've done VB, so I could be wrong.
Thanks Valman.

Am not 100% sure what you mean.

Is Form an inbuilt VB6 class, or would I need to create a public class module called from, or whatever, that consists of Set() and Get() provate functions, and not much else?

Or am I WAAAAAY of the mark here?
Gary.Goodbye, and thanks for all the fish.
I meant the built in VB6 class that represents a form. I believe it's called Form.

And I think I was wrong about the public variable, because forms can't have them. But you reminded me of public Get/Set properties - I am pretty sure forms can have those. So just use a get/set to create a public interface to Caller variable, and keep the variable itself private. You would do this for every form that will want to know who called/showed it.
Thanks Valman

Will check it out, and let you know...
Gary.Goodbye, and thanks for all the fish.

This topic is closed to new replies.

Advertisement