VB.NET

Moderators: seancampbell
Number of threads: 4022
Number of posts: 10035

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Pass data from Form A to Form B Posted by SteveWaltari on 21 Sept 2005 at 7:35 PM
Suppose that Form A has a button that when clicked creates Form B.

How do you pass information from Form A to Form B?

Report
Re: Pass data from Form A to Form B Posted by biohazard 2.0 on 21 Sept 2005 at 9:54 PM
: Suppose that Form A has a button that when clicked creates Form B.
:
: How do you pass information from Form A to Form B?
:
:
What specific data would you want to pass?

you could pass all sorts of Data are you looking at passing text, images, ECT?

Report
Re: Pass data from Form A to Form B Posted by Grinja on 22 Sept 2005 at 3:52 AM
: : Suppose that Form A has a button that when clicked creates Form B.
: :
: : How do you pass information from Form A to Form B?
: :
: :
: What specific data would you want to pass?
:
: you could pass all sorts of Data are you looking at passing text, images, ECT?
:
:

Assuming you want to pass an integer:

In Form B

#Region " Windows Form Designer generated code "

Public Sub New(ByVal xValue As Integer)

valX = xValue


#End Region

'Before Form Load
Dim valX As Integer


In Form A:
'Code behind Button

dim xValue as integer

xValue = 20 'Or any integer value you want to pass
Dim frm As New frmB(xValue)


Hope this helps.























Report
Re: Pass data from Form A to Form B Posted by SteveWaltari on 22 Sept 2005 at 8:15 AM
: : : Suppose that Form A has a button that when clicked creates Form B.
: : :
: : : How do you pass information from Form A to Form B?
: : :
: : :
: : What specific data would you want to pass?
: :
: : you could pass all sorts of Data are you looking at passing text, images, ECT?
: :
: :
:
: Assuming you want to pass an integer:
:
: In Form B
:
: #Region " Windows Form Designer generated code "
:
: Public Sub New(ByVal xValue As Integer)
:
: valX = xValue
:
:
: #End Region
:
: 'Before Form Load
: Dim valX As Integer
:
:
: In Form A:
: 'Code behind Button
:
: dim xValue as integer
:
: xValue = 20 'Or any integer value you want to pass
: Dim frm As New frmB(xValue)
:
:
: Hope this helps.
:
:
:
: That helps alot...I wasn't aware of the "New" method. Seems like I should have been since it's basicly a constructor for the form!

Thanks a bunch!
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:
:

Report
Re: Pass data from Form A to Form B Posted by paulmorrison on 22 Sept 2005 at 5:20 PM
: : : : Suppose that Form A has a button that when clicked creates Form B.
: : : :
: : : : How do you pass information from Form A to Form B?
: : : :
: : : :
: : : What specific data would you want to pass?
: : :
: : : you could pass all sorts of Data are you looking at passing text, images, ECT?
: : :
: : :
: :
: : Assuming you want to pass an integer:
: :
: : In Form B
: :
: : #Region " Windows Form Designer generated code "
: :
: : Public Sub New(ByVal xValue As Integer)
: :
: : valX = xValue
: :
: :
: : #End Region
: :
: : 'Before Form Load
: : Dim valX As Integer
: :
: :
: : In Form A:
: : 'Code behind Button
: :
: : dim xValue as integer
: :
: : xValue = 20 'Or any integer value you want to pass
: : Dim frm As New frmB(xValue)
: :
: :
: : Hope this helps.
: :
: :
: :
: : That helps alot...I wasn't aware of the "New" method. Seems like I should have been since it's basicly a constructor for the form!
:
: Thanks a bunch!
: :
: :
: :
: :
: :
: :
: :
: :
: :
: :
: :
: :
: :
: :
: :
: :
: :
: :
: :
: :
:
:
Or by
Dim Shared X as String (in formA)

then in formB
you could set varible Y - formA.X


Report
Re: Pass data from Form A to Form B Posted by SteveWaltari on 23 Sept 2005 at 7:37 AM
: : : : : Suppose that Form A has a button that when clicked creates Form B.
: : : : :
: : : : : How do you pass information from Form A to Form B?
: : : : :
: : : : :
: : : : What specific data would you want to pass?
: : : :
: : : : you could pass all sorts of Data are you looking at passing text, images, ECT?
: : : :
: : : :
: : :
: : : Assuming you want to pass an integer:
: : :
: : : In Form B
: : :
: : : #Region " Windows Form Designer generated code "
: : :
: : : Public Sub New(ByVal xValue As Integer)
: : :
: : : valX = xValue
: : :
: : :
: : : #End Region
: : :
: : : 'Before Form Load
: : : Dim valX As Integer
: : :
: : :
: : : In Form A:
: : : 'Code behind Button
: : :
: : : dim xValue as integer
: : :
: : : xValue = 20 'Or any integer value you want to pass
: : : Dim frm As New frmB(xValue)
: : :
: : :
: : : Hope this helps.
: : :
: : :
: : :
: : : That helps alot...I wasn't aware of the "New" method. Seems like I should have been since it's basicly a constructor for the form!
: :
: : Thanks a bunch!
: : :
: : :
: : :
: : :
: : :
: : :
: : :
: : :
: : :
: : :
: : :
: : :
: : :
: : :
: : :
: : :
: : :
: : :
: : :
: : :
: :
: :
: Or by
: Dim Shared X as String (in formA)
:
: then in formB
: you could set varible Y - formA.X
:
:Does the New() method have to be in the windows generated code region?
:I'm wondering now, because I tried this method and during runntime, when i called the form without arguments, the form would show as designed, but if I called the form with arguments, a blank form would show. I had the New() method outside of the windows generated code region, now I wonder if this is the reason why.
:
:



Report
Re: Pass data from Form A to Form B Posted by Grinja on 26 Sept 2005 at 2:58 AM
: : : : : : Suppose that Form A has a button that when clicked creates Form B.
: : : : : :
: : : : : : How do you pass information from Form A to Form B?
: : : : : :
: : : : : :
: : : : : What specific data would you want to pass?
: : : : :
: : : : : you could pass all sorts of Data are you looking at passing text, images, ECT?
: : : : :
: : : : :
: : : :
: : : : Assuming you want to pass an integer:
: : : :
: : : : In Form B
: : : :
: : : : #Region " Windows Form Designer generated code "
: : : :
: : : : Public Sub New(ByVal xValue As Integer)
: : : :
: : : : valX = xValue
: : : :
: : : :
: : : : #End Region
: : : :
: : : : 'Before Form Load
: : : : Dim valX As Integer
: : : :
: : : :
: : : : In Form A:
: : : : 'Code behind Button
: : : :
: : : : dim xValue as integer
: : : :
: : : : xValue = 20 'Or any integer value you want to pass
: : : : Dim frm As New frmB(xValue)
: : : :
: : : :
: : : : Hope this helps.
: : : :
: : : :
: : : :
: : : : That helps alot...I wasn't aware of the "New" method. Seems like I should have been since it's basicly a constructor for the form!
: : :
: : : Thanks a bunch!
: : : :
: : : :
: : : :
: : : :
: : : :
: : : :
: : : :
: : : :
: : : :
: : : :
: : : :
: : : :
: : : :
: : : :
: : : :
: : : :
: : : :
: : : :
: : : :
: : : :
: : :
: : :
: : Or by
: : Dim Shared X as String (in formA)
: :
: : then in formB
: : you could set varible Y - formA.X
: :
: :Does the New() method have to be in the windows generated code region?
: :I'm wondering now, because I tried this method and during runntime, when i called the form without arguments, the form would show as designed, but if I called the form with arguments, a blank form would show. I had the New() method outside of the windows generated code region, now I wonder if this is the reason why.
: :
: :
:
:
:
:
Im not sure if it will make a difference, I have only tried it with the code in the windows generated code.
Report
Re: Pass data from Form A to Form B Posted by rlc on 26 Sept 2005 at 6:07 AM
It does not matter where it is, basically you are overloading the constructors funciton's signiture. When you do this which is fine make sure to call the componentInit function for the form(I forget what it is called look in the generated constructor). If you dont call this function it won't create the controls for the IDE.

~rlc

Report
Re: Pass data from Form A to Form B Posted by digitalgeek on 1 Oct 2005 at 1:41 PM


Another possilbilty would be if you need to populate a label or text box to simply assign a value to the text property...

dim fb as new formb

fb.label1.text = "The text you need to pass"

any object in formb is accessible with this method





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.