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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert a string to a form object 2

Status
Not open for further replies.

cruise95

Programmer
Oct 7, 2003
56
US
I am creating a wizard that contains next and back buttons. When the user selects next, then a certain form is loaded and the name of the form is placed in an array. Then when the user selects the back button the previous entry in the array contains the name of the previous form. Ideally the previous form should then be brought. The code I'm thinking about is similar to the following:


sub btnBack_click(...) Handles ...
Dim prevFormName As String
Dim prevForm

formArrayList.removeAt(formArrayList.count-1)

prevFormName = formArrayList(count-1)
prevForm = New CType(prevFormName, form)
prevForm.showDialog()

Me.close
end sub
 
Are you storing the name of the form in your string, or are you storing the form itself (ie a serialized copy of the form instance)?

Chip H.


____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
I am storing the name of the form in the string (the previously called form names are in an array list that acts as a stack)

I am just storing the name so I don't have to store the entire object in memory.
 
I think it would be significantly easier to just store each form in the array list. Yes, it will take more memory, but you wont have to recreate forms each time the user hits next/last and the user's settings will remain.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Like Rick says -- just store the form.

It's actually not that bad, as memory is abundant these days. Anyway, your memory costs will be:

1) The form and it's contents (large, yes)
2) Any variables which reference the form (36 bytes each)

So as long as you only have one instance of the form in memory, you can maintain quite a large number of variables which point to it before running into memory issues.

Chip H.


____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
Thanks guys -

Memory is abundant and my little forms shouldn't eat up that much anyway. What I've done is set up a global, multidimensional hash table to hold all the variables. I close and open the forms where needed. Thanks for the suggestions -

Frank
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top