473,626 Members | 3,936 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pass back data

Hei
Hi All,

i using .showdialog to show a child form for user input some data,
and i wand to pass back these data to the parent form.
how can i achieve this?

thx.
Hei.

Nov 20 '05 #1
3 1328
Hei,

If you consider the form as a class (as it really is) then you could set
create public properties that are accessible from your parent form.

For instance

Dim child as New Form

child.ShowDialo g()
' child does it stuff setting public properties and
' then finally call the Me.Hide method from a command button

' Control is back to the parent
Debug.Writeline (child.Property 1)
Debug.Writeline (child.Property 2)
' etc..

child.Dispose()
child = Nothing

HTH,
Dan
"Hei" <ch******@msn.c om> wrote in message
news:OH******** ******@TK2MSFTN GP11.phx.gbl...
Hi All,

i using .showdialog to show a child form for user input some data,
and i wand to pass back these data to the parent form.
how can i achieve this?

thx.
Hei.

Nov 20 '05 #2
> i using .showdialog to show a child form for user input some data,
and i wand to pass back these data to the parent form.
how can i achieve this?


Property Procedures:

Let's say we have a Login Form with this stuff on it:

txtUsername
txtPassword
btnOK
btnCancel

You want to set the following relevant properties on the property sheet:

txtPassword.Pas swordChar = *
btnOK.DialogRes ult = OK
btnCancel.Dialo gResult = Cancel
Login.AcceptBut ton = btnOK
Login.CancelBut ton = btnCancel
Login.FormBorde rStyle = Dialog

Then inside the form's code, you would write stuff like this:

Public Class Login
Inherits Windows.Forms.F orm

'I am leaving out the designer-generated code

'I am assuming that code outside this assembly should
'never be able to get the username or password,
'hence the Friend access modifier

Friend Property Username As String
Get
Return txtUsername.Tex t
End Get
Set(ByVal username As String)
txtUsername.Tex t = username
End Set
End Property

Friend Property Password As String
Get
Return txtPassword.Tex t
End Get
Set(ByVal password As String)
txtPassword = password
End Set
End Property

'You will probably have other code too. This is a cheesy sample.
End Class

Now, in the application that uses this dialog, you can use it similar to the
way that you use the other common dialog components. 1. make a new one, 2.
set default properties, 3. call ShowDialog, 4. get the results:

Dim f As New Login()
Dim username As String
Dim password As String

f.ShowDialog()

username = f.Username
password = f.Password

f = Nothing

Security Note:

For this particular example, I happened to use a login dialog because it's
something familiar and easy to build as a sample. My code here, though, is
focused on the answer to the question, and not security. I don't think that
any custom login should ever pass the password as a string. If this code
were cleaned up for security purposes, the Password.Get block would return a
Hash of the password, not the password itself.

--
Peace & happy computing,

Mike Labosh, MCSD
Owner, vbSensei.Com
"Escriba coda ergo sum." -- vbSensei
Nov 20 '05 #3
* "Hei" <ch******@msn.c om> scripsit:
i using .showdialog to show a child form for user input some data,
and i wand to pass back these data to the parent form.
how can i achieve this?


See:

<http://groups.google.d e/groups?selm=u5Y 8SnOXDHA.1872%4 0TK2MSFTNGP12.p hx.gbl>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

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

Similar topics

2
4593
by: Matt | last post by:
How to pass data back and forth between ASP and JSP page? Let's say I have Java objects, how to pass the data back to ASP page?? Or ASP has data, how to pass the data to JSP page?? Please advise. Thanks!
0
2438
by: Matt | last post by:
My problem is to allow ASP to interact with JSP, and I pass JavaScript object in my approach, but I wonder if it will work in network, not just in local machine. For testing purposes, the following are page1.html and page2.html that use Array JavaScript object to pass data back and forth. page1.html is able to transfer data to page2.html, but page2.html has trouble to transfer data back to page1.html.
7
2068
by: liyang3 | last post by:
Hi, I have Class A, B and C. Class A has an instance of B. Class B has an instance of C. In the instance of C, it generates some data that need to be passed back to Class A. But Class C doesnot know anything about Class A. I'm dealing with legacy code. What is the best way to implement it and have the code change to existing classes such as A and B small? Any
3
1615
by: Chris | last post by:
I have a modal (yes it must be modal) web page. I do this by having an empty frame that points to my main page (so that I can repost without new popups) I have to pass data to the child page from the parent and the only way I can figure to do it by the url. Please correct me if I'm wrong on that. When the data get to my frame I then have to pass the data to my child form, again through the url (i think). The only way I found to do...
8
6573
by: darrel | last post by:
I'm still trying to fully understand how best to pass variables between pages/usercontrols/each other. On a current site I've done, I've had one userControl do the logic and set the variable, and then I had other usercontrols simply read this by traversing the class structure: siteClass.userControlClass.specficVariable. That worked fine. The new site I'm working on is a bit different, as I'm using multiple
5
7814
by: David++ | last post by:
Hi folks, I would be interested to hear peoples views on whether or not 'pass by reference' is allowed when using a Web Service method. The thing that troubles me about pass-by-reference into a WebService is that essentially we are passing an address of an object which resides on the 'local machine' i.e. a local machine object address. Surely when the WebService method is called and run 'on the server', the reference type will be...
3
1525
by: =?Utf-8?B?UmljaCBIdXRjaGlucw==?= | last post by:
I have a form, Form1, that shows an instance of Form2 when a user clicks a button. On Form2, the user is to select items, Customer Names for example, from a datagrid control. When the user clicks a button on Form2, I want to pass the text of the selected Customer Names in the datagrid back to a listbox control on Form1, but I'm stuck as to how to access the listbox back on Form1. I have no problem getting the information I want from the...
14
3599
by: =?Utf-8?B?Umljaw==?= | last post by:
I have seen examples of passing data from FormB to FormA (Parent To Child) but I need an example of passind data from FormA to FormB. My main form is FormA; I will enter some data in textboxes and click a button to bring up FormB which needs to display values entered in FormA. Thanks in advance.
9
2547
by: JRough | last post by:
I tried to pass the $result from a mysql_query in a url like this line Header("Location:clm_historyXL.php?_result=".$result); but on the redirect location clm_history.php page I get an error on this line: $result = $_POST; I need the $result on the clm_historyXL page to print a list to excel because of a header already being sent.
3
5449
Frinavale
by: Frinavale | last post by:
I've created a few ASP.NET Ajax Enable Server controls. There are 2 components to these controls: a server side Object that deals with the server side stuffs, and a client side Object that deals with the client side stuff. My controls are pretty nifty and quite useful but I keep coming back come back to the same question: How do I pass data from the JavaScript Object to the Server code? Up 'til now I've been using HiddenFields in...
0
8266
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8705
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8638
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8505
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7196
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5574
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2626
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

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.