473,396 Members | 1,940 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,396 software developers and data experts.

Passing parameters between various Forms

Hi,

I have created a new form which gets initialized by an event.

Private Sub btnScenGenerate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnScenGenerate.Click

Dim Test As FormTest = New FormTest

Test.ShowDialog(Me)

End Sub

The new form is the only one active and we need to kill it to get back to the original form. And this exactly what I want.

My question is: what is the best way to pass info from the original form into the second ?

For example I want to pass a string form fMainForm to formTest.

TIA

-steve

Nov 21 '05 #1
3 973
'Having your Main Form pass info to your test form.
Dim Test As FormTest = New FormTest()
Test.SomeTextBox.Text = Me.someString

'Having your Test form pull info from your Main Form
'Declared inside your TestForm class
Dim parentForm As MainForm()
parentForm = DirectCast(parentForm, MainForm)
Me.SomeTextBox.Text = parentForm.someString

"steve" wrote:
Hi,

I have created a new form which gets initialized by an event.

Private Sub btnScenGenerate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnScenGenerate.Click

Dim Test As FormTest = New FormTest

Test.ShowDialog(Me)

End Sub

The new form is the only one active and we need to kill it to get back to the original form. And this exactly what I want.

My question is: what is the best way to pass info from the original form into the second ?

For example I want to pass a string form fMainForm to formTest.

TIA

-steve

Nov 21 '05 #2

"rmacias" <rm*****@newsgroup.nospam> wrote in message
news:7F**********************************@microsof t.com...
'Having your Main Form pass info to your test form.
Dim Test As FormTest = New FormTest()
Test.SomeTextBox.Text = Me.someString

IMHO this is really bad form. It ties your calling code to tightly to your
form. Use either paramaters in the forms constructor or use public
properties instead. That way you can do this....

Dim Test As FormTest
Test = New FormTest(argument1, argment2, argument3)
Test.Show()

OR

Dim Test as New FormTest()
Test.Arg1 = "string1"
Test.Arg2 = "string2"
Test.Arg3 = 'string3"
Test.Show()

'Having your Test form pull info from your Main Form
'Declared inside your TestForm class
Dim parentForm As MainForm()
parentForm = DirectCast(parentForm, MainForm)
Me.SomeTextBox.Text = parentForm.someString

"steve" wrote:
Hi,

I have created a new form which gets initialized by an event.

Private Sub btnScenGenerate_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnScenGenerate.Click

Dim Test As FormTest = New FormTest

Test.ShowDialog(Me)

End Sub

The new form is the only one active and we need to kill it to get back to
the original form. And this exactly what I want.

My question is: what is the best way to pass info from the original form
into the second ?

For example I want to pass a string form fMainForm to formTest.

TIA

-steve

Nov 21 '05 #3
I see.

Thanx for your advice.
However , using Show() means that I can still put focus on the parent form.
Should I use ShowDialog(Me) instead or is there a better way ?

TIA
-steve

"Ray Cassick (Home)" <rc************@enterprocity.com> a écrit dans le
message de news: ey**************@TK2MSFTNGP09.phx.gbl...

"rmacias" <rm*****@newsgroup.nospam> wrote in message
news:7F**********************************@microsof t.com...
'Having your Main Form pass info to your test form.
Dim Test As FormTest = New FormTest()
Test.SomeTextBox.Text = Me.someString


IMHO this is really bad form. It ties your calling code to tightly to your
form. Use either paramaters in the forms constructor or use public
properties instead. That way you can do this....

Dim Test As FormTest
Test = New FormTest(argument1, argment2, argument3)
Test.Show()

OR

Dim Test as New FormTest()
Test.Arg1 = "string1"
Test.Arg2 = "string2"
Test.Arg3 = 'string3"
Test.Show()

'Having your Test form pull info from your Main Form
'Declared inside your TestForm class
Dim parentForm As MainForm()
parentForm = DirectCast(parentForm, MainForm)
Me.SomeTextBox.Text = parentForm.someString

"steve" wrote:
Hi,

I have created a new form which gets initialized by an event.

Private Sub btnScenGenerate_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnScenGenerate.Click

Dim Test As FormTest = New FormTest

Test.ShowDialog(Me)

End Sub

The new form is the only one active and we need to kill it to get back
to the original form. And this exactly what I want.

My question is: what is the best way to pass info from the original form
into the second ?

For example I want to pass a string form fMainForm to formTest.

TIA

-steve


Nov 21 '05 #4

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

Similar topics

1
by: JD | last post by:
I posted this earlier and it disappeared from the NewsGroup I want to pass two parameters to a simple script running on my web server. The script "parpass.php" looks like this: <?php echo...
8
by: Alex Vinokur | last post by:
Various forms of argument passing ================================= C/C++ Performance Tests ======================= Using C/C++ Program Perfometer...
8
by: RC | last post by:
In my Access 2002 form, I have a combo box and on the AfterUpdate event I use DoCmd.RunSQL ("UPDATE .... to update records in a table. When it starts to run I get a message "You are about to...
2
by: Bob | last post by:
I'm new to Access projects and SQL server and am not a veteran VB programmer. There's a cry for help! I'm attempting to print the current form on screen by using a command button which the user...
0
by: Zlatko Matiæ | last post by:
Hi everybody! Recently I was struggling with client/server issues in MS Access/PostgreSQL combination. Although Access is intuitive and easy to use desktop database solution, many problems...
11
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
8
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
5
by: Rod | last post by:
I've written 2 ASP.NET applications (I've worked on one with a team and another by myself). In my ASP.NET pages, when saving data to a backend database I've done it by using the click event of a...
7
by: Ceebaby via AccessMonster.com | last post by:
Hi All Here's hoping someone can help me with this. I have a report based on a query where the criteria for 4 of the fields is set from an unbound form. I want the user to be able to select any...
7
by: salzan | last post by:
I have a form in which I collect info from the user and then process various tables. Now, I need to call a report and pass two parameters to it so it’ll only select the desired records for...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.