• Advertisement
Sign in to follow this  

VB6 - Genric globals

This topic is 3315 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement