fortypoundhead.com

How to pass data between forms in vb6 ?

ShoNuff asked this question on 12/7/2011. It has been viewed 1504 times, and is currently resolved.

I want to know how can I pass data between forms in vb6?

For example: If I have 2forms that contain 2 text boxes , how can i use a button to transfer what's written in a textbox to the other .

Hope You have Answers.

Keywords:

Answer from dwirch on 12/11/2011

In the button click event on form1, you can write directly to the text box on form2, thus:

form2.text1.text = form1.text1.text

This will take the text string in text1 of form1 and plug it in at text1 on form2.

Or you can use global variables. This comes in handy if you want to close the current form before opening the other form. When your event fires (button click, etc), store your value in the global variable. Then, when the other form opens, or on some other event, you can pick up the value from the variable.

The second option is a bit more flexible too, since that value can now be read from any routine that needs it. The first method is more hard-wired, and can only be used for one thing.

Reference:



Recent Forum Posts

Malicious IP Checker Companion Tool
dwirch posted on August 12, 2017 at about 20:24 in Site News

Job Spammer: Steve Adams
dwirch posted on August 8, 2017 at about 7:44 in Spammers

New security implemented
dwirch posted on August 8, 2017 at about 6:43 in Site News

New security implemented
dwirch posted on July 23, 2017 at about 6:58 in Site News

Fold Code Manager into main KB?
VB6Boy posted on July 22, 2017 at about 14:42 in Site News

Fold Code Manager into main KB?
dwirch posted on July 22, 2017 at about 14:41 in Site News