472,328 Members | 1,651 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

VB 6 LOAD form to VB.NET Question

I am trying to learn VB.Net and can't figure out how to call a from from
another form. In VB6, I just issue a Load FormX, and an Unload FormX... and
Show the form and there it is.

I am sure it is obvious, but I can't see how to do that in VB.net. Does
someone have a piece of code that will call a from from another form and
have it appear.

Thanks,

Michael Erlewine
mi*****@erlewine.ent
Nov 21 '05 #1
7 8473
"Michael Erlewine" <mi*****@erlewine.net> wrote in news:BQGMd.26503
$1*******@fe06.lga:
I am trying to learn VB.Net and can't figure out how to call a from from
another form. In VB6, I just issue a Load FormX, and an Unload FormX... and Show the form and there it is.

I am sure it is obvious, but I can't see how to do that in VB.net. Does
someone have a piece of code that will call a from from another form and
have it appear.

Thanks,

Michael Erlewine
mi*****@erlewine.ent


dim f2 as new form2
f2.show
'once f2 closes we return here
'f2 is still available, and could be shown again
'we can get info from f2 still:
myString = f2.TextBox1.text
'dispose will get rid of the form
f2.dispose
Nov 21 '05 #2
j00ls code does the trick, but it's worth explaining.

In .NET everything you work with is an object. So, when you add a form to
your project what you are creating is a class containing code that defines
the look, feel and behaviour of the form. To load the form then, you have to
instantiate the class. It's the same as if I'd defined a class called Pete
and wanted an object from it

Dim myPete as New Pete()

That turns my Pete class into an object. So, if you have a form class called
Form2 (as in J00ls code) you'll need to first turn that class into an object

Dim myForm as new Form2()

Then, having turned it into an object, you can go ahead and call methods on
it, like Show()

myForm.Show()
Hope that makes sense. Take a look at the programming with objects guides in
the online help for more info on how to do OO with VB.NET. It's weird at
first when you move across from VB6, but ultimately it makes a lot more
sense than the old VB6 way of doing things.

--
Pete Wright
Author of ADO.NET Novice to Pro for Apress
www.petewright.org

"Michael Erlewine" <mi*****@erlewine.net> wrote in message
news:BQ******************@fe06.lga...
I am trying to learn VB.Net and can't figure out how to call a from from
another form. In VB6, I just issue a Load FormX, and an Unload FormX... and
Show the form and there it is.

I am sure it is obvious, but I can't see how to do that in VB.net. Does
someone have a piece of code that will call a from from another form and
have it appear.

Thanks,

Michael Erlewine
mi*****@erlewine.ent

Nov 21 '05 #3
Michael,

"Michael Erlewine" <mi*****@erlewine.net> schrieb:
I am trying to learn VB.Net and can't figure out how to call a from from
another form. In VB6, I just issue a Load FormX, and an Unload FormX... and
Show the form and there it is.


There is no 'Load' and 'Unload' any more. Forms in .NET are "normal"
classes.

Showing a form:

\\\
Dim f As New FooForm()
f.Show()
///

Showing a form modally:

\\\
Dim f As New FooForm()
f.ShowDialog()
f.Dispose()
///

Notice that forms which are shown modally are not disposed automatically
when they are closed, that's why you should call 'Dispose' explicitly.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4
Thanks all of you for that first step, which brings me to the gate of
the second step: How do I create that 2nd form to be loaded?

In VB6, I just ADD a blank form, populate it with controls, and then
call it. How do I do that in VB.net

Thanks,

Michael Erlewine

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #5
I got the Form to load and I figured out how to ADD A FORM to the
project. I have another question.

Much of my work is in FoxPro. All I need is to read a FREE .DBF table,
and transfer the data to variables in VD.net and use them.

I installed the VFP OLE DB data provider.

Now I need to see a sample piece of code that works that reads a free
DBF table using a search for a unique character phrase in one field, and
then gets data from a couple other character fields and a couple of Memo
Fields. Any help would be appreciated.

Thanks,

Michael Erlewine

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #6
I am getting BUILD ERRORS like"Type 'Introduction' is not Defined."

'Introduction is the name of a form I am using.

The code looks like this:

Dim f3 As New Introduction()
F3.ShowDialog()
f3.dispose()

Any ideas?
Thanks,

Michael Erlewine
mi*****@erlewine.ent
Nov 21 '05 #7
On Fri, 04 Feb 2005 06:17:44 -0800, Michael Erlewine <mi*****@erlewine.net> wrote:

I got the Form to load and I figured out how to ADD A FORM to the
project. I have another question.

Much of my work is in FoxPro. All I need is to read a FREE .DBF table,
and transfer the data to variables in VD.net and use them.

I installed the VFP OLE DB data provider.

Now I need to see a sample piece of code that works that reads a free
DBF table using a search for a unique character phrase in one field, and
then gets data from a couple other character fields and a couple of Memo
Fields. Any help would be appreciated.


See the following:

Accessing Visual FoxPro Data in Visual Studio .NET
http://msdn.microsoft.com/library/de...lstudionet.asp
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Marc | last post by:
When I add controls to a form and run the .exe under Win XP, the outline of the form displays first and then the controls on the form. The .exe...
11
by: Johnny M | last post by:
I have several databases where I have one form to add a new record and one form to edit an existing record. I use unbound forms and class modules...
3
by: ChadDiesel | last post by:
I'm new to Access and need some advice. I am trying to setup a database to print labels and reports for our shipments. I have set up a table with...
4
by: Dan | last post by:
I am back yet again :) I am encountering an Exception that has me scratching my head. I have two forms. Form A launches Form B in response to...
4
by: Paul | last post by:
Is there any way of making the following code into a function so that I don't have to re-use the same code for all my buttons? I've tried to do this...
1
by: adam | last post by:
I have a simple form question. I order to access a payment gateway I have a asp.net page which has to have a form that use POST for method and...
3
by: MacDermott | last post by:
The help file in Access 2000 has entries for Load and Show, suggesting a usage similar to that in VB6.0. But code like this fails: Dim Frm as...
8
by: Mitch5713 | last post by:
I've got tthree forms at start up splashscreen- works fine however how do i set the time delay so it stays on the window longer,, shows longer??...
10
by: sara | last post by:
Hi - I have been struggling with solution ideas for this now for almost 2 weeks, and have not been able to figure this out. I have a user who...
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
1
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.