473,322 Members | 1,562 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,322 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 1304
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.