Click here to Skip to main content
15,895,777 members
Please Sign up or sign in to vote.
2.00/5 (4 votes)
See more:
Please help me, I have a project and have 3 form, form 1 is for name and lastname, form 2 is for school and university, form 3 is to display all the data ..How can i display data from textbox1 in form 1 and form 2 to form 3??



Look Guys ..
To make my problem clear
I have two forms..

Form 1: 1 textbox and 1 button ( button don't show the name that user enter in txtbox but open form 2)

Form 2: 1 txtbox and button, (in txtbox form 1 user enter name) in this txtbox form 2 the user enter his lastname...The button will show a msgbox wich show up the name and lastname..


how can i do it?


I tried like thi: but it doesn't work out :/

VB
Private Sub Command1_Click()
Static name As Integer
Static lastname As Integer
firstname = txtFirstName.Text
LastName = txtLastName.Text
txtFirstName.Text = Form1.txtFirstName.Text
txtLastName.Text = Form2.txtLastName.Text

both = (Form1.txtFirstName.Text " & & " Form2.txtLastName.Text)
MsgBox (both)

End Sub
Posted
Updated 31-Dec-12 8:37am
v4
Comments
Richard C Bishop 27-Dec-12 15:19pm    
Post the code of the forms your have so far.
San Dra 30-Dec-12 10:20am    
How?
Sergey Alexandrovich Kryukov 27-Dec-12 15:31pm    
Not quite a good question. What do you mean how? How to write code? What part of it? It's hard to help if you don't explain a particular problem.
—SA
San Dra 30-Dec-12 10:21am    
I mean where I have to write the code?



Look Guys ..
To make my problem clear
I have to forms..
Form 1: 1 textbox and 1 button ( button don't show the name that user enter in txtbox but open form 2)
Form 2: 1 txtbox and button, (in txtbox form 1 user enter name) in this txtbox form 2 the user enter his lastname...The button will show a msgbox wich show up the name and lastname..


how can i do it?


I tried like thi: but it doesn't work out :/

<pre lang="vb">Private Sub Command1_Click()
Static name As Integer
Static lastname As Integer
firstname = txtFirstName.Text
LastName = txtLastName.Text
txtFirstName.Text = Form1.txtFirstName.Text
txtLastName.Text = Form2.txtLastName.Text

both = (Form1.txtFirstName.Text " & & " Form2.txtLastName.Text)
MsgBox (both)

End Sub</pre>

I have stuck
Sergey Alexandrovich Kryukov 30-Dec-12 13:14pm    
OK, is your problem solved by now?
—SA

Yo might to create some container , where you can store all data from various forms.
But one thing that you should consider, this holder/container must behaves like singleton! Use singleton pattern for it!

And one important moment, in future , please , primiraly try to write some code by yourself , and only in case of some confusion or error , ask comunnity for help!
 
Share this answer
 
Comments
San Dra 30-Dec-12 10:24am    
I have a project with student grades, but include their names..now how do I display in the end all the data from forms previous..?
This is the popular question about form collaboration. The most robust solution is implementation of an appropriate interface in form class and passing the interface reference instead of reference to a "whole instance" of a Form. Please see my past solution for more detail: How to copy all the items between listboxes in two forms[^].

Please also see other solutions in this discussion. If the application is simple enough, the solution could be as simple as declaring of some internal property in one form and passing a reference to the instance of one form to the instance of another form. For more complex projects, such violation of strictly encapsulated style and loose coupling could add up the the accidental complexity of the code and invite mistakes, so the well-encapsulated solution would be preferable.

Please see also:
http://en.wikipedia.org/wiki/Accidental_complexity[^],
http://en.wikipedia.org/wiki/Loose_coupling[^].

I would also add that your design does not seem good. I would strongly advise to review it, but I cannot suggest any particular design as right now I don't know your goals. First of all, I would avoid multi-form design at all. In most cases, one but more complex form is quite enough, but it also more convenient for the users. What you have now as a separate form can become some container control. Such as Panel or TabPage. You can hide one panel and show another one, you can activate different pages of TabControl, one at a time, or even develop more complex dockable design (similar to that of Visual Studio). Please think about it.

Happy New Year!

—SA
 
Share this answer
 
Comments
San Dra 31-Dec-12 16:41pm    
Thank you very much..

Happy new year too ^_^
Sergey Alexandrovich Kryukov 31-Dec-12 17:38pm    
Thank you,
—SA
Place TextBox or LabelBox, or DataGridView in Your 3rd Form
Here i've Write Code to Display Details from Form1 and From2 to TextBox(s) in Form3...

txtFristName.Text = Form1.txtFirstName.Text



Write Similar Code for all Fields,

If this answer not you Looking for? Just Improve your Question and Be Specific with your Problem...
 
Share this answer
 
v2
Comments
Christian Graus 28-Dec-12 0:46am    
This is really awful, about the worst possible solution. No form should ever expose it's UI elements.
Ashok19r91d 28-Dec-12 0:55am    
Who say so? Objects Properties can be right to access from Anywhere in Project... Only thing Your Object have Modifiers Property of Object to Friend...

This Solution not applicable for Webforms...
Christian Graus 28-Dec-12 2:00am    
Sure - there's always a difference between what a beginner will do because it works, and what a real programmer does to write a clean, maintainable system. This will work. It's just ugly and not suitable for real world systems.
Ashok19r91d 28-Dec-12 2:17am    
If so Ignore my My Solution, Sorry for wasting your time...
Sergey Alexandrovich Kryukov 31-Dec-12 17:36pm    
It's too late to ignore... :-) Or does it mean that you don't want to listen to anything negative and hence don't want to learn on your mistakes? Christian meant to help you to learn one really practically important principle, which could be really useful for you, and what? — would you rather tend to close your eyes on good advice? If this is so, you can hardly learn...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900