|
-
Sep 13th, 2010, 03:50 PM
#1
Thread Starter
Addicted Member
Error Set f = Form1 [HELP]
Let's say I have this:
Code:
Dim f as Form
Set f = New Form
If there is no form named "Form1" will fail to create ...
My question is:
How I can declare sure there is an form with the same name in the project so I will not return an error?
Thanks
-
Sep 13th, 2010, 04:04 PM
#2
Addicted Member
Re: Error Set f = Form1 [HELP]
I think u have to select which form will declared for F
for example u have From named frmMain so your code will be:
Code:
Dim F As Form
Set F = New frmMain
then u can do what u want for example make the caption of frmMain equal to caption of F,Like this:
Code:
F.Caption = "VBForums"
frmMain.Caption = F.Caption
hope that is what you want
Regards.
Last edited by Programmation; Sep 13th, 2010 at 04:29 PM.
-
Sep 13th, 2010, 06:24 PM
#3
Thread Starter
Addicted Member
Re: Error Set f = Form1 [HELP]
Thanks but that was not what I wanted ...
I will explain better:
I have a function to create a new form ... then put this:
vb Code:
Dim f as Form Set f = New Form1
But if the draft is not an exact form called "Form1" is not going to work ...
How do I fix this?
Do I explain myself?
Thanks
-
Sep 13th, 2010, 06:25 PM
#4
Re: Error Set f = Form1 [HELP]
 Originally Posted by *PsyKE1*
Let's say I have this:
Code:
Dim f as Form
Set f = New Form
If there is no form named "Form1" will fail to create ...
My question is:
How I can declare sure there is an form with the same name in the project so I will not return an error?
Thanks
Don't you know the names of the forms in your project?
-
Sep 13th, 2010, 06:33 PM
#5
Re: Error Set f = Form1 [HELP]
Are you trying to create a form at RunTime?
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Sep 13th, 2010, 06:33 PM
#6
Thread Starter
Addicted Member
Re: Error Set f = Form1 [HELP]
Are you trying to create a form at RunTime?
Yes i do 
Don't you know the names of the forms in your project?
of course!
But I'm trying to make my function as generic as possible.
Creeuna I want a copy of any form of my project.
CallByName could help?
Thanks
-
Sep 13th, 2010, 06:43 PM
#7
Re: Error Set f = Form1 [HELP]
You can use callByName to set property values or to call procedures but you can't create forms (or anything else) by using it.
-
Sep 13th, 2010, 06:48 PM
#8
Re: Error Set f = Form1 [HELP]
You can do the following but I don't know why you'd want to.
Code:
Public Sub CreateForm(frm As Object)
frm.Show
End Sub
Usage:
Code:
CreateForm Form2 ' Where Form2 is an existing form in your project
-
Sep 13th, 2010, 06:57 PM
#9
Thread Starter
Addicted Member
Re: Error Set f = Form1 [HELP]
Thanks, but it isnt that i found...
I want to create a reply of any Form which is in my proyect, runtime...
Really Thanks
-
Sep 14th, 2010, 01:17 PM
#10
Re: Error Set f = Form1 [HELP]
In order to create a new instance of a form/object, you need to use the keyword NEW. And I don't think you can use a variable or reference as the form/object.
Last edited by LaVolpe; Sep 14th, 2010 at 01:21 PM.
-
Sep 14th, 2010, 01:24 PM
#11
Re: Error Set f = Form1 [HELP]
How about
vb Code:
Public Sub ShowForm(ByVal pstrFormName As String)
Dim MyForm As Form
Set MyForm = Forms.Add(pstrFormName)
MyForm.Show
End Sub
Private Sub Command1_CLick()
ShowForm "Form2"
End Sub
-
Sep 14th, 2010, 01:28 PM
#12
Re: Error Set f = Form1 [HELP]
Hack, crud! You beat me to it. I just re-discovered the same thing.
For Psyke1. I still don't see the advantage of building a function/sub to create a new instance of a form. I have no idea what that sub/function will do with the created form, but if it adds controls, modifies form properties, I think this would be more intuitive (code-wise) and less involved
Code:
Dim f As Form
Set f = New Form1
' now call a sub and pass f so that new controls can be added or properties changed
But your project, your call. Don't forget to add error trapping in case the passed form name is not part of the project.
-
Sep 15th, 2010, 12:46 AM
#13
PowerPoster
Re: Error Set f = Form1 [HELP]
You will be required to add in some sort of error checking process, that is built into your COM Project...
Try making it look, like this:
Code:
On Error Goto ...........
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|