Convert string variable into form object in VB6

Thread Solved

Join Date: Jan 2008
Posts: 7
Reputation: Neophyte08 is an unknown quantity at this point 
Solved Threads: 0
Neophyte08 Neophyte08 is offline Offline
Newbie Poster

Convert string variable into form object in VB6

 
0
  #1
Jan 4th, 2008
hello there,

anyone can help...
is this possible?
i have a string value of form names in my DB so when my condition passes, the variable string will take over the value , then that value will call the form(variable) as string.
i got an error when i use this code.

dim objForm as form
dim sValue as string

sValue="frmXXX"

set objForm=sValue
objForm.show

This is what the code looks like... i need to convert the variable string to form object

thanks a lot.
Last edited by Neophyte08; Jan 4th, 2008 at 5:37 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 62
Reputation: Mbt925 is an unknown quantity at this point 
Solved Threads: 5
Mbt925's Avatar
Mbt925 Mbt925 is offline Offline
Junior Poster in Training

Re: Convert string variable into form object in VB6

 
0
  #2
Jan 4th, 2008
This sample may help :
Attached Files
File Type: zip Con_Str2Obj_Form.zip (2.0 KB, 215 views)
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 7
Reputation: Neophyte08 is an unknown quantity at this point 
Solved Threads: 0
Neophyte08 Neophyte08 is offline Offline
Newbie Poster

Re: Convert string variable into form object in VB6

 
0
  #3
Jan 6th, 2008
Originally Posted by Mbt925 View Post
This sample may help :
Mbt925, thank you so much for the help...
You have a good solution... i already do that kind of code, only applies to loaded/Active forms but in my case i will not load any form on it, just call them even unload/inactive...
just convert the string variable into object form name that i really needed.

thank you so much for the help...
maybe you have some ideas about this, i just want to call/show the forms in a generic way, i made a program to be a user defined function call.

is this idea possible? any help pls.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 62
Reputation: Mbt925 is an unknown quantity at this point 
Solved Threads: 5
Mbt925's Avatar
Mbt925 Mbt925 is offline Offline
Junior Poster in Training

Re: Convert string variable into form object in VB6

 
0
  #4
Jan 7th, 2008
Your welcome my friend.

you can't convert string to object directly .
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 7
Reputation: Neophyte08 is an unknown quantity at this point 
Solved Threads: 0
Neophyte08 Neophyte08 is offline Offline
Newbie Poster

Re: Convert string variable into form object in VB6

 
0
  #5
Jan 7th, 2008
yah! i know its hard to do, but i am just asking if it is possible...
i already got the answer to my question. their is another way how to show the form via variable and my problem solved already...
thanks a lot for the support... hope we could share again later some ideas in developing software.

well, if you dont mind can i have your asl pls?
thanks! God bless.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 62
Reputation: Mbt925 is an unknown quantity at this point 
Solved Threads: 5
Mbt925's Avatar
Mbt925 Mbt925 is offline Offline
Junior Poster in Training

Re: Convert string variable into form object in VB6

 
0
  #6
Jan 8th, 2008
Originally Posted by Neophyte08 View Post
i already got the answer to my question. their is another way how to show the form via variable and my problem solved already...
if possible , put your answer for this problem here ?
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 218
Reputation: hkdani is an unknown quantity at this point 
Solved Threads: 24
hkdani's Avatar
hkdani hkdani is offline Offline
Posting Whiz in Training

Re: Convert string variable into form object in VB6

 
0
  #7
Jan 8th, 2008
dim objForm as form
dim sValue as string

sValue="frmXXX"

set objForm=sValue
objForm.show

This is what the code looks like... i need to convert the variable string to form object

thanks a lot.
If you already have the forms made, that really shouldn't be a problem. Use a Select CASE statement.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim strFormName as String
  2.  
  3. Select strFormName
  4.  
  5. Case "formXXX"
  6. formXXX.show
  7. Case "FormX1"
  8. FormX1.show
  9. Case "FormX2"
  10. FormX2.show
  11. End Select
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 7
Reputation: Neophyte08 is an unknown quantity at this point 
Solved Threads: 0
Neophyte08 Neophyte08 is offline Offline
Newbie Poster

Re: Convert string variable into form object in VB6

 
0
  #8
Jan 9th, 2008
Originally Posted by Mbt925 View Post
if possible , put your answer for this problem here ?
yah! ok...
well, in my solution you can solved in two ways, provided the form exist in your project
if not error will take over:

sValue="frmXXX"

#1 'You can use the add command
set frmName=forms.add("sValue")
frmName.show

#2 'Using the CallByName function in VB6
set frmName=CallByName(Forms,"Add",vbMethod,sValue)
frmName.show

you can use either of this two solution i have.
This idea comes in my mind its because i managed more than a hundred forms in one project and i dont want a conditions or a hard coded, it makes your code messy.

anyone can use this code...
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 7
Reputation: Neophyte08 is an unknown quantity at this point 
Solved Threads: 0
Neophyte08 Neophyte08 is offline Offline
Newbie Poster

Re: Convert string variable into form object in VB6

 
0
  #9
Jan 9th, 2008
Originally Posted by hkdani View Post
If you already have the forms made, that really shouldn't be a problem. Use a Select CASE statement.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim strFormName as String
  2.  
  3. Select strFormName
  4.  
  5. Case "formXXX"
  6. formXXX.show
  7. Case "FormX1"
  8. FormX1.show
  9. Case "FormX2"
  10. FormX2.show
  11. End Select

hi hkdani,
Thank you so much for the solution I really appreciated.
Well, that was my old approach or old way of showing form,
i put it in the module all of them.
i think that could be applied to less than a hundred forms, what if you have more than a hundred you will declare all.

what i am trying here is to call the specific form from the table without any conditions and hard coded way, all are variables.

as of now i have more than 150 forms in a project.

thank you, hope we could share ideas later.
God Bless my friend.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC