473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Cant solve this easy problem

Hi Folks

I am starting to learn VB.NET. A problem that i have encountered is that i cannot seem to use the values in my textbox accross forms

for example i have 2 forms. On form2 i have a search facility that allows the user to search for the guests in a hotel. When the user has selected a guest from the datagrid the chosen guest details are placed in numerous textboxes using the databinding)
What i want to do now is when the guest clicks the Exit button, i want the text that is in the textboxes in form2 to appear in the textboxes in form1

Is there anyway i can do this?

In VB6 i could just use the form name to do this. i.
Form1.textbox1.text = Form2.textbox2.text
Jul 21 '05 #1
5 1308
Set public properties in the second form, Value1 and Value2 for instance.
Then, make sure you set them before form2 closes. You'll be able to
reference them from the same code block that you called Show() or
ShowDialog() from
"Varun" <an*******@discussions.microsoft.com> wrote in message
news:C2**********************************@microsof t.com...
Hi Folks,

I am starting to learn VB.NET. A problem that i have encountered is that i cannot seem to use the values in my textbox accross forms.
for example i have 2 forms. On form2 i have a search facility that allows the user to search for the guests in a hotel. When the user has selected a
guest from the datagrid the chosen guest details are placed in numerous
textboxes using the databinding). What i want to do now is when the guest clicks the Exit button, i want the text that is in the textboxes in form2 to appear in the textboxes in form1.
Is there anyway i can do this??

In VB6 i could just use the form name to do this. i.e
Form1.textbox1.text = Form2.textbox2.text

Jul 21 '05 #2
Hi William

How would i create a public property

Public Value2 as string ???

Also i confuse by what you say when talking about referencing these values.
Are you saying i can use these varibles to fill the textboxes on form1 before i display it

i.e when i use the Form2.close on the exit buttons onclick event?

many thx
Jul 21 '05 #3
Public Property Whatever as WhateverType
Get
Return WhateverPrivateVariable
Set
WhateverPrivateVariable = Value
End Property

Then in the first form

Dim f as New SecondForm
f.ShowDialog

Dim s as WhateverType = f.Whatever
"Varun" <an*******@discussions.microsoft.com> wrote in message
news:AF**********************************@microsof t.com...
Hi William,

How would i create a public property?

Public Value2 as string ????

Also i confuse by what you say when talking about referencing these values. Are you saying i can use these varibles to fill the textboxes on form1 before i display it.
i.e when i use the Form2.close on the exit buttons onclick event??

many thx

Jul 21 '05 #4
You can have a data propogation logic instead of making variables public or keeping the form instance in the memory to get the data from that.

Overload the form class constructors for data passage, you can pass the data via resepective objects or you can stuff all the required objects in a hashtable and pass that hashtable to second form via overloaded constructor.

"Varun" wrote:
Hi Folks,

I am starting to learn VB.NET. A problem that i have encountered is that i cannot seem to use the values in my textbox accross forms.

for example i have 2 forms. On form2 i have a search facility that allows the user to search for the guests in a hotel. When the user has selected a guest from the datagrid the chosen guest details are placed in numerous textboxes using the databinding).
What i want to do now is when the guest clicks the Exit button, i want the text that is in the textboxes in form2 to appear in the textboxes in form1.

Is there anyway i can do this??

In VB6 i could just use the form name to do this. i.e
Form1.textbox1.text = Form2.textbox2.text

Jul 21 '05 #5
Hi Varun

Adding to the advise that you have been given.

Take a look at this article. It shows you one way of accessing Controls
across Forms in .NET

http://www.devcity.net/net/article.a...multipleforms2

Hope this helps with your problem.

Neil Knobbe
Visual Basic MVP
"Varun" <an*******@discussions.microsoft.com> wrote in message
news:C2**********************************@microsof t.com...
Hi Folks,

I am starting to learn VB.NET. A problem that i have encountered is that i cannot seem to use the values in my textbox accross forms.
for example i have 2 forms. On form2 i have a search facility that allows the user to search for the guests in a hotel. When the user has selected a
guest from the datagrid the chosen guest details are placed in numerous
textboxes using the databinding). What i want to do now is when the guest clicks the Exit button, i want the text that is in the textboxes in form2 to appear in the textboxes in form1.
Is there anyway i can do this??

In VB6 i could just use the form name to do this. i.e
Form1.textbox1.text = Form2.textbox2.text

Jul 21 '05 #6

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

Similar topics

2
by: Nikolai Onken | last post by:
Hey, I got a rather more mathematical Problem but have no idea how to solve it: I have following values and want them to return other values as stated below: (Best seen with fixed pitch font)...
102
by: Skybuck Flying | last post by:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C compilers produce so many error messages as soon as a closing bracket is missing. The response was simply because the compiler...
8
by: Daniel Billingsley | last post by:
I've got to believe this is a fairly common / classic problem, and I think I've even read an example somewhere in my education thus far, but I sure can't remember it. Suppose I want to store a...
8
by: Mas L via DotNetMonster.com | last post by:
Hi, I have a c++ source code which I can compile to be a DLL (in VS.NET 2003). And I need to use it in a C# program. After I compiled/build the C++ code to a DLL, I add it as a Reference in my...
1
by: t322y | last post by:
Hi All I installed Microsoft.Net Framework Version:1.0.3705.209 (included ASP.NET Version:1.0.3705.0) in my Win 2000 SP3 3 weeks ago. It worked well all until i installed a free softwore GoMono. I...
5
by: Varun | last post by:
Hi Folks I am starting to learn VB.NET. A problem that i have encountered is that i cannot seem to use the values in my textbox accross forms for example i have 2 forms. On form2 i have a...
1
by: WStoreyII | last post by:
I am trying to make a finances database. I have a master table which contains transaction header info and then a line details table. What i want is to make a reconcile query where i can see...
1
by: otupia | last post by:
Exercise : Given the diagram below. Transform the diagram into C++ program. Class Grade Private members :char letter;float score; Public Members :void SetScore( float );float GetScore(...
0
Sakalicek
by: Sakalicek | last post by:
Hello all, I have serious problem and have no idea how to solve it, of course :) I have Web Service which has master page. This side is the client side. On master page there are some submit...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...

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.