Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hi everybody ! i am facing one problem in microsoft visual basic 4.0

Status
Not open for further replies.

makarandpatil

Programmer
Mar 31, 1999
2
0
0
US
hi everybody !<br>
i am facing one problem in microsoft visual basic 4.0<br>
(32 bit) here it is.....<br>
<br>
Form1 having array of text box controls with numbers inside it and facility to Add OR Remove controls and<br>
Also, buttons OK and CANCEL are there.<br>
<br>
WHEN I CLICK OK IT SHOULD CREATE ARRAY OF, NUMBERS I TYPED<br>
IN TEXT BOX CONTROL ON FORM2 WHICH IS MY ANOTHER FORM.<br>
<br>
WHEN I RELOAD FORM1 AFTER CLICKING CANCEL IT SHOULD LOAD <br>
THE PREVIOUS NUMBER OF CONTROLS ALONG WITH THEIR RELEVANT<br>
VALUES WHATEVER IS IT.<br>
<br>
can we use arrays like public variable<br>
<br>
if possible mail me at : makarand.patil@usa.net<br>
with some example code<br>
<br>
Thanks <br>
<br>
makarand m. patil<br>
<br>

 
Hi makarandpatil !<br>
<br>
Yes, you need to separate the data from it's presentation (the forms). I would do something like create a class module with public properties of:<br>
-- Control Size (x,y,cx,cy)<br>
-- Control Value<br>
<br>
I would then create a .bas module that contains an instance of a global collection.<br>
<br>
As the user adds/removes controls on Form1, also add and remove members of the collection. The members being, of course, instances of your class.<br>
<br>
When it comes time to show Form2, and all the values from Form1, you can just do a For..Each loop through the collection, adding the .Value property to the textbox.<br>
<br>
When the user clicks 'Cancel' on Form2, to go back to Form1, you again loop through the collection, using the control size info to recreate the control array, and stuff the .Value into the controls.<br>
<br>
By separating the data from the view of the data, you make things much more flexible, and easier to add features later.<br>
<br>
Chip H.<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top