Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 17974
Number of posts: 55343

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How to Show a Form in VB.NET Posted by SoulBurn18 on 17 Mar 2005 at 6:34 PM
I am working on a program and I need to click a button on the main form (we'll call it frmForm1). When I click the button on frmForm1, I want frmForm2 to appear. However when I click on the button, nothing happens. The code I used is as follows

frmForm2.Show()

I know that works with VB6, but it doesn't seem to work with .NET. Can anybody tell me what the code is to make a form appear?

Thanks in advance.
Report
Re: How to Show a Form in VB.NET Posted by HackmanC on 18 Mar 2005 at 11:08 AM
This message was edited by HackmanC at 2005-3-18 11:12:4

You only have the prototype of an object, in other words you only have a class. (The correct way of do this is the same .. but in VB6... you did have the shortcut you seems to use).

Dim f As frmForm2
f = New frmForm2
f.Show(...) ' f.ShowModal(...)

Remember to use a modal form. Or it goes away as it apears. ('cause the var goes out of scope).

------
: I am working on a program and I need to click a button on the main form (we'll call it frmForm1). When I click the button on frmForm1, I want frmForm2 to appear. However when I click on the button, nothing happens. The code I used is as follows
:
: frmForm2.Show()
:
: I know that works with VB6, but it doesn't seem to work with .NET. Can anybody tell me what the code is to make a form appear?
:
: Thanks in advance.
:

Good luck!
Hackman



Report
Re: How to Show a Form in VB.NET Posted by SoulBurn18 on 18 Mar 2005 at 12:24 PM
Thanks Hackman, just tried it and it worked beautifully. I appreciate the help.
Report
Re: How to Show a Form in VB.NET Posted by HopeZ on 19 Mar 2005 at 3:27 AM
You have to creat object of form before you use it.
For Example:
Dim myForm As Form1 'Declare myForm for Form1
myForm=New Form1 'Creat form object
myForm.Show 'myForm uses method "Show" of Form







 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.