|
-
Jun 16th, 2004, 12:03 PM
#1
Thread Starter
Member
Loading form2
What am I missing here, in Excel VB macro I can use load form2 and then form2.show to load and show a second form.
With visual studio (vb) I have Form1 with a button, when you click the button I want to show Form2. All help files I've found do this;
Dim formx as New Form()
formx.ShowDialog()
Sure, that works, but that gives an empty form, not my form.
In my solution explorer I see Form1.vb and Form2.vb, but;
load form2 changes to Load(Form2) with error;
'Form2' is a type and cannot be used as an expression.
form2.show changes to form2.show() with error;
Reference to a non-shared member requires an object reference.
I've also added;
Imports projectname.Form2
which exact use I do not know, but I thought it a declaration because perhaps Form2 isn't in my scope, but still doesn't work.
In short, what are the code lines to load form2 from form1?
-
Jun 16th, 2004, 12:34 PM
#2
Hyperactive Member
-
Jun 16th, 2004, 01:27 PM
#3
Thread Starter
Member
Thanks for the solution 
I totally misunderstood what was happening, I thought I could use my form2 as an object, but it isn't an object, it's a 'blue print' of what I want my form to look like so i have to first create an instance of it by using;
dim F2 as form2
F2.showdialog
while I was trying to use it directly with things like;
form2.showdialog
You can't use any form you create yourself, but you can create an instance of it and use that.
Nice how something can seem so 100% logical after some help
-
Jun 16th, 2004, 02:33 PM
#4
Frenzied Member
The form you create in the IDE is a class. You have to instantiate an instance of the class to get an actual form.
-
Jun 16th, 2004, 04:25 PM
#5
Hyperactive Member
Salvelinus is right, but I think you have already catched the meaning.
Always happy to be useful....bye and good night!
Live long and prosper (Mr. Spock)
-
Jun 17th, 2004, 05:21 AM
#6
PowerPoster
Originally posted by cphoenixc
Thanks for the solution 
I totally misunderstood what was happening, I thought I could use my form2 as an object, but it isn't an object, it's a 'blue print' of what I want my form to look like so i have to first create an instance of it by using;
dim F2 as form2
F2.showdialog
while I was trying to use it directly with things like;
form2.showdialog
You can't use any form you create yourself, but you can create an instance of it and use that.
Nice how something can seem so 100% logical after some help
Just in case you missed it, should be:
Dim F2 As NEW form2
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
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
|