By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,264 Members | 1,277 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,264 IT Pros & Developers. It's quick & easy.

Convert String, To Object, Then To Form

devonknows
100+
P: 137
Hi, The problem im having is, Im creating a user control. The user (via the Property Page's) will set his own menu titles, and the choose a form of which that title links to. If that makes sense.

So the form names are stored in string data, how can i convert it from a string to an object or to a form so that when someone clicks on the title the form will show. Is there a way to loop though form names?

But i dont want to have to add and if-then-else statement or select-case statement for every form i have.
Example:
Expand|Select|Wrap|Line Numbers
  1. if  txtFormName.Text = "frmMain" then
  2.     frmMain.show
  3. end if
Any help again would be appreciated
Kind Regards
Devon
Feb 1 '08 #1
Share this Question
Share on Google+
7 Replies


Expert 5K+
P: 8,434
What version of Vb is this in?
Feb 1 '08 #2

devonknows
100+
P: 137
What version of Vb is this in?
The version im using is VB6 (Microsoft Visual Studio 6)

Kind Regards
Devon
Feb 1 '08 #3

devonknows
100+
P: 137
The version im using is VB6 (Microsoft Visual Studio 6)

Kind Regards
Devon
Just bumping this up
any help would be appreciated

Kind Regards
Devon
Mar 9 '08 #4

Expert 5K+
P: 8,434
Try looping through the Forms collection until you hit the one with the required name. Or was it caption... whatever.
Mar 10 '08 #5

devonknows
100+
P: 137
Try looping through the Forms collection until you hit the one with the required name. Or was it caption... whatever.
i tried what you asked but wen i used

dim frm as Form
for each frm in forms
if frm.name = arrFrm(Index)
next

all it does is it searches through the forms that are already open/loaded
but with the amount of forms that i have it would be inpractical and it would use laods of resources loading them all.

is there anyway to loop through the forms that arn't open/loaded?

Kind Regards
Devon
Mar 14 '08 #6

Expert 5K+
P: 8,434
I don't know the answer to that, but I wonder whether you could work around it by maintaining your own array or collection, updating it in the forms' load/unload event procedures. given the need to identify forms that aren't currently loaded (and presumably may never have been loaded yet) I think you'd need to load up the complete array/collection at startup. Then use the event procedures to maintain a current status of each form.

Granted it's a pretty ugly way of goling about it, but it's the best I can come up with at the moment. Does it sound doable? I don't recall enough about the prior discussion to say one way or the other.
Mar 17 '08 #7

Expert 5K+
P: 8,434
Oops!

Just re-read some of the earlier messages and it looks as though my suggestion will be no help whatsoever. Sorry about that.

Can't think of anything better right now.
Mar 17 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.