Please help with passing data from one form to another form

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2006
Posts: 1
Reputation: wisorac is an unknown quantity at this point 
Solved Threads: 0
wisorac wisorac is offline Offline
Newbie Poster

Please help with passing data from one form to another form

 
0
  #1
Apr 20th, 2006
Hello!
I have a project to where I am making a pizza order for customers. My forms consist of a form for the pizza quantity and size (the cost is displayed in a lblDisplay.Text). I also have another form which calculates the cost of beverages.

I am now on the third form which calculates the cost of side items. I need to make it to where when the user clicks the submit button that the total of the side items is displayed along with adding the total of the pizzas and beverages of the other two forms. I dont know how to grab data from other forms.

I can make the other forms load by using the

Dim XXXX as new frmXXX

If my question is not clear enough, please let me know.

Adam
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5
Reputation: Ammar Gaffar is an unknown quantity at this point 
Solved Threads: 1
Ammar Gaffar Ammar Gaffar is offline Offline
Newbie Poster

Re: Please help with passing data from one form to another form

 
0
  #2
Apr 26th, 2006
Hi Adam,

I will give the method , regardless about your project take the method then apply it with any project

There two common methods is used for passing data between forms

The first one is by creating a properties in the form that you want to pass the data on it

for example if you have two forms the the first one (name it Form1) include one textbox control and button , and when pressing button you want to pass the textbox text to the second form (name it Form2)

the property shold be like :

Note these codes in Form2
  1. Private _passedText As String
  2.  
  3. Public Property [PassedText]() As String
  4. Get
  5. Return _passedText
  6. End Get
  7. Set(ByVal Value As String)
  8. _passedText= Value
  9. End Set
  10. End Property
Then , when you are declaring Object from Form2 you just set The Value before Showing the Form

in the Form1 and in Button1 Click event write these lines :
  1. Dim Obj As New Form2
  2. Obj.PassedText = TextBox1.Text
  3. Obj.Show

by this way you have the text in the Form2 - variable _passedText

hope you get it , if you didnt I am here

The Second Method by Adding parameters to the Form that you need to pass the data on it in Sub New - I didnt like it , the Properties is better


Good Luck
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 32
Reputation: DATABASE is an unknown quantity at this point 
Solved Threads: 0
DATABASE DATABASE is offline Offline
Light Poster

Re: Please help with passing data from one form to another form

 
0
  #3
May 26th, 2006
hi


i want to pass a text from a textbox in form1 to a label in form2 , but the text in form1 is retrieved from a database. how could i do it??:rolleyes:



Edit ...... thanx i solve the problem
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 12
Reputation: khwo is an unknown quantity at this point 
Solved Threads: 0
khwo khwo is offline Offline
Newbie Poster

Re: Please help with passing data from one form to another form

 
0
  #4
Jul 7th, 2006
Hi Ammar Gaffar,

If I want to pass around 10 data from form1 to form2, it iz I still can using this method? or got other method to pass more than 1 data from form to form?
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5
Reputation: Ammar Gaffar is an unknown quantity at this point 
Solved Threads: 1
Ammar Gaffar Ammar Gaffar is offline Offline
Newbie Poster

Re: Please help with passing data from one form to another form

 
0
  #5
Jul 8th, 2006
Hi KhWo ,

It dosnt matter how many Variables you need to Pass , just create a property for each variable , Object , or any other types

Good Luck
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 10
Reputation: Zhoot is an unknown quantity at this point 
Solved Threads: 1
Zhoot Zhoot is offline Offline
Newbie Poster

Re: Please help with passing data from one form to another form

 
0
  #6
Jan 30th, 2008
*Bump*
Do this also work in VB 6? I'm new to the language and tested out your code but I only experience alot of failures.

Thx
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Please help with passing data from one form to another form

 
0
  #7
Jan 30th, 2008
in vb 6 you can access it directly
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 10
Reputation: Zhoot is an unknown quantity at this point 
Solved Threads: 1
Zhoot Zhoot is offline Offline
Newbie Poster

Re: Please help with passing data from one form to another form

 
0
  #8
Jan 31st, 2008
Thank you!

So if I create a variable in Form1, then it will automatically exist in Form2 once it opens? Cool!
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Please help with passing data from one form to another form

 
0
  #9
Jan 31st, 2008
nice to hear that.
happy coding friends...
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 42
Reputation: fawadkhalil is an unknown quantity at this point 
Solved Threads: 0
fawadkhalil fawadkhalil is offline Offline
Light Poster

Re: Please help with passing data from one form to another form

 
0
  #10
Dec 29th, 2008
Originally Posted by Ammar Gaffar View Post
Hi Adam,

I will give the method , regardless about your project take the method then apply it with any project

There two common methods is used for passing data between forms

The first one is by creating a properties in the form that you want to pass the data on it

for example if you have two forms the the first one (name it Form1) include one textbox control and button , and when pressing button you want to pass the textbox text to the second form (name it Form2)

the property shold be like :

Note these codes in Form2
  1. Private _passedText As String
  2.  
  3. Public Property [PassedText]() As String
  4. Get
  5. Return _passedText
  6. End Get
  7. Set(ByVal Value As String)
  8. _passedText= Value
  9. End Set
  10. End Property
Then , when you are declaring Object from Form2 you just set The Value before Showing the Form

in the Form1 and in Button1 Click event write these lines :
  1. Dim Obj As New Form2
  2. Obj.PassedText = TextBox1.Text
  3. Obj.Show

by this way you have the text in the Form2 - variable _passedText

hope you get it , if you didnt I am here

The Second Method by Adding parameters to the Form that you need to pass the data on it in Sub New - I didnt like it , the Properties is better


Good Luck
Hi i tried this code and it really works.But without obj.Show it didnt.
Whats the function of obj.Show here?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC