473,549 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How does one simply open one form from another ?

As an old programmer just now looking at VB.net I have a question:

How does one simply open one form from another ? I don't mean how does one
create a new instance of that form , but rather how to refer to THAT form ?
And having done this, how does one get data to and from that form ?

I have read the MS tutorial on this but it is senselessly complex; there
must be a simple, straightforward method, or I can only assume that MS has
destroyed a useful tool (VB) in the absurd following of the OO obsession
.....
Nov 21 '05 #1
17 8591
Barret,

I don't know what that usefull tool is, however you now create different
kind of forms and directly from your main form.

There are MDI child forms, dialogforms and normal form.
Basicly it is all the same however the way of showing is different

for a normal form it is
\\\
dim frm as new form2
frm.show
///

That is all.

I hope this helps?

Cor

"Barret Bonden"
As an old programmer just now looking at VB.net I have a question:

How does one simply open one form from another ? I don't mean how does one
create a new instance of that form , but rather how to refer to THAT form
?
And having done this, how does one get data to and from that form ?

I have read the MS tutorial on this but it is senselessly complex; there
must be a simple, straightforward method, or I can only assume that MS has
destroyed a useful tool (VB) in the absurd following of the OO obsession
....

Nov 21 '05 #2
"Barret Bonden" <ar****@network s-cc.com> schrieb:
As an old programmer just now looking at VB.net I have a
question:

How does one simply open one form from another ? I don't
mean how does one create a new instance of that form , but
rather how to refer to THAT form ? And having done this,
how does one get data to and from that form ?
You'll have to store references to your forms' default instances somewhere,
or implement the Singleton design pattern for your form classes for easily
accessing the default instances.
I have read the MS tutorial on this but it is senselessly
complex; there must be a simple, straightforward method,
or I can only assume that MS has destroyed a useful tool
(VB) in the absurd following of the OO obsession


ACK. Hopefully, default instances for forms will be back in VB 2005.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #3

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote

ACK. Hopefully, default instances for forms will be back in VB 2005.

Why would you want auto-instantiating forms back? They were the
source of many problems including 'My app won't shut down' type
of problems. The main point is that no other objects are auto-instantiating
so why make forms act that way?

IMHO it would be better to tell the developer how to add that functionality,
rather than have it included in the language. If they include it, we all have to
live with it, but if there is a simple workaround to bring it back, then those
who want it, can have it, while those who don't won't have to consider it a
possible source for errors.

Doesn't this code provide that functionality:

Module Module1
Public MyForm1 As New Form1
Public MyForm2 As New Form2
End Module
With the above, both MyForm1 and MyForm2 are auto-instantiating.

IMHO, That would be the better solution. What do you think?

LFS
Nov 21 '05 #4
"Larry Serflaten" <se*******@usin ternet.com> schrieb:
ACK. Hopefully, default instances for forms will be back in VB 2005.


Why would you want auto-instantiating forms back?


Take a look how many beginners cannot be productive because they need to
understand the current form model. The current model is nice, but IMO a
simplification would be a step forward to a more RAD experience, especially
for beginners.

Notice that I do not talk about the current implementation (beta versions of
Whidbey). This implementation definitely sucks. But the problems can be
fixed.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #5
Herfried,

In my idea wrong
Take a look how many beginners cannot be productive because they need to
understand the current form model. The current model is nice, but IMO a
simplification would be a step forward to a more RAD experience,
especially for beginners.

That sentence should be in my opinion.

Take a look how many persons who where used to VB6 and than go
on............. ...

That is a very bad reason.

There will be more and more beginners who never saw VB6 and than you keep
them on the bad methods.

I have the same idea in this as Larry (not his solution. It is well as it is
now in my idea).

Just my thought as you know

Cor
Nov 21 '05 #6
"Cor Ligthert" <no************ @planet.nl> schrieb:
Take a look how many beginners cannot be productive
because they need to understand the current form model.
[...]
That sentence should be in my opinion.

Take a look how many persons who where used to VB6 and than go
on............. ...

That is a very bad reason.


That's another story.

On the one hand, there are those VB6 developers who make their first steps
with VB.NET and miss default instances and the simplicity known from VB6.

On the other hand, there are complete newbies who are not fully aware of OOP
programming and thus have problems to deal with different forms, accessing
controls on other forms' instances, etc.

A solution to the issue needs to satisfy both of the groups described above.
There will be more and more beginners who never saw VB6
and than you keep them on the bad methods.


Default instances in general are /not/ a bad method. They are a valuable
shortcut.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #7

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote
Why would you want auto-instantiating forms back?
Take a look how many beginners cannot be productive because they need to
understand the current form model.


Cor added more on the point I was making: The people who have trouble
are those who are expecting VB6 fucntionality. Programming 'beginners'
over the next decade (or more) will not have that predisposition, and to them,
forms should act just like every other class in the framework.
Notice that I do not talk about the current implementation (beta versions of
Whidbey). This implementation definitely sucks. But the problems can be
fixed.


I don't have the 2005 beta installed, but I hear talk that the forms will be
available through the My.Forms shortcut. In that instance I could see where
auto-instantiation might be the better way to go, but to add that functionality
globally is (IMHO) a large mistake.

LFS
Nov 21 '05 #8
"Larry Serflaten" <se*******@usin ternet.com> schrieb:
> Why would you want auto-instantiating forms back?
Take a look how many beginners cannot be productive
because they need to understand the current form model.


Cor added more on the point I was making: The people
who have trouble are those who are expecting VB6 fucntionality.


I agree, they expect VB6 functionality.

But many newbies (without exprience with VB6) are confused by the
complicated form model too. It's simply unpractical. It's too complicated
to manage references to forms when only one instance of a form is needed.

In VB6, a newbie simply typed 'Call Form1.Show' and the form was shown.
He/she typed 'Form1.BackColo r = vbRed' and the form's backcolor turned into
red. It was much easier to access the single instance of a form. No need
for implementing a Singleton or creating a reference store somewhere.
Programming 'beginners' over the next decade (or more) will
not have that predisposition, and to them, forms should act
just like every other class in the framework.
OOP is hard to understand, especially for beginners. Beginners start with
procedures and do not care about objects. But beginners want to be
productive in order to experience playing around with the programming
language as an interesting and fascinating task. I remember the time when I
developed my first Visual Basic application. Creating it was sooo easy. I
didn't have to know much about "objects", "references ", "instances" , ...

If VB.NET should be a language designed for beginners too, then an easier
way to create an applications UI infrastructure is required. A large number
of beginners will lead to a large number of professional developers using a
certain programming language. Programming languages that introduce
complexity by adding heavy requirements like full knowledge of OOP when
writing their first program, won't have a future.
I don't have the 2005 beta installed, but I hear talk that the
forms will be available through the My.Forms shortcut.


That's right. Notice that the default instances will only be created "by
need", so if you don't use them, don't worry about them.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #9

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote
Default instances in general are /not/ a bad method. They are a valuable
shortcut.

I'd suggest they are bad.

1. They are the source of problems when the app is shutting down
2. They are a source of problems when some use default styles while
others use explicit, in the same program.
3. They would be an unexplained exception to the patterns used by all
other classes in the language.

Adding a form to a project does not 'call it into existance by default'
any more than adding other classes. Having to explicitly declare the
forms is no different than explicitly declaring other classes. It is also
not far from having to explicitly declare variables, so the concept is
not going to be totally unfamiliar to the novice. With Option Explicit
on, variables have to be declared before use, and are constrained by
scoping issues. There is very little different when looking at objects.

The kicker is that, if you insert that functionality globally, then everyone
has to deal with it, where as if you simply provide a work around you
get two benefits:

1. The functionality is made available
2. The users are reminded that a 'workaround' is not normal use.
(IOW it may be better for them to deal with it in a more uniform way)

I realize this is a polarizing issue, some like it one way, and others like it
the other, but again, if it gets added, we all have to deal with it. Why
add a stumbling block to normal development???

LFS


Nov 21 '05 #10

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

Similar topics

11
2003
by: Saqib Ali | last post by:
Please excuse me, this is a fairly involved question that will likely require you to save the file below to a file and open it in a browser. I use Mozilla 1.5, so the problem I describe below should be reproducible with that version at least. BACKGROUND: =========== When you open this page in your browser, you will see a 4 cell table....
3
34488
by: trellow | last post by:
Hello, I am writing an application that needs to read a file that is already open by another process for writing. When I do the following: FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); I get the following exception:
5
2455
by: twick10 | last post by:
Hi, I am trying to execute a control method on an open form (not with focus) from a modal dialog box. I want to increment the node selected from the dialog when a certain key is pressed. Any help appreciated. Robert T
4
9851
by: jaYPee | last post by:
I know how to open a form from another form. Say open form2 from form1 using a command button. But my problem is everytime I clicked the button it open again another instance of that form. here's my code Dim Course As New Course Course.Show() My question is on how to prevent a form from opening again if it is
2
6323
by: allyn44 | last post by:
Hello, I have built a serch form for users to edit records. I only want them to pull up the record they need, and I want to check for nulls. There should not be dupes becasue the underlying tables are indexed. So the user will pull up either one record or none. Here is my problem: I pass the form name through a tmpvariable and ther other...
6
3093
by: Moumen VB.NET 2003/2005 Developer | last post by:
How can I detect if a file sitting on a network drive is still open by another application? This application resides on another machine on the network? I am using VB.NET 2003 Your help is highly appreciated
3
10553
by: kev | last post by:
Hi folks, I have a form for registration (frmRegistration) whereby i have two buttons. One is Save which saves record using the OnClick property. I used wizard to create the save button. The other one is Next button which i created to open another form "frmSummary" which displays back the records submitted. (i used the wizard to open form...
14
25004
by: keri | last post by:
Hi, Simple version of the question..... How do I use the where clause of the open form command to show an account with a matching ID to be displayed when the form is opened? Eg. I select a record on a continuous form and click and edit button. The button runs the open form code. I want the APPID of the current record on the continous...
1
1342
by: andrew smith | last post by:
Problem is with the designer... // opens in designer // (has reason not to (undefined)) public class BaseForm<T>: Form { } // doesn't open in design (it should) public class StringFormBase: BaseForm<String>
0
7532
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7730
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7823
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5101
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3510
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1957
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1069
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
777
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.