Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 152
  • Last Modified:

Load form with the use of variables

Hi Experts,

I am facing a problem in loading forms in VB, by calling the form name through a variable. Like :

dim ank as string
ank = "frmMain"
Load ank

the above code is giving me problems and I am unable to figure out a way to get past this problem. I think that the solution would be easy for you experts with years experience but silly me could not get through this small problem. I would really appreciate all the help I can get with this problem of mine.

Chalo that will be all for now. TAKE CARE you guys and gals.

Thanks in advance. :):):)

Joyriderank.
0
joyriderank
Asked:
joyriderank
  • 2
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
unfortunately, even we with years of experience don't have anything except workarounds for this problem. Unless the form is not loaded, you can't get it's object reference and check it's name, and thus you can't load one (as the load function requests an object).
CHeers
0
 
TimCotteeHead of Software ServicesCommented:
angelIII you can use this of course:

Dim frmToLoad As Form
dim ank as string
ank = "frmMain"
Set frmToLoad = Forms.Add (Ank)

which does work. Of course if the string contains a form that is not present in the project then an error will occur but this can be trapped and handled in the usual way.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
sorry, you are right... but this is new in VB6, I start to loose my vb-knowledge, doing too much stuff in db :(
CHeers
0
 
joyriderankAuthor Commented:
Thanks for your help with the problem guys. I will check out your suggestion TimCottee and get back to you if I face any problems.

Chalo that will be all for now. TAKE CARE guys. :):):)

Joyriderank.
0
 
joyriderankAuthor Commented:
Thanks TimCottee for the answer. It wroked just great. Thanx a lot for the advice.

Take Care.

Joyriderank.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now