Linking the text value from different forms

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Aug 2008
Posts: 28
Reputation: nor_d83 is an unknown quantity at this point 
Solved Threads: 0
nor_d83 nor_d83 is offline Offline
Light Poster

Linking the text value from different forms

 
0
  #1
Jan 24th, 2009
Hello everybody.. Here I have a question regarding my “Budget System” project. It’s about to link the annual budget amount (txtBudget) from form 1 to the (txtBudget) in the form 2. It means that the system user have to set the value txtBudget in the form 1, so that it appears in the form 2 txtBudget, consequently to show the balance in txtBalance after being reducted using the MSFlexGrid codes below…

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub cmdCalculate_Click()
  2. Dim i As Integer
  3. Dim TAmt As Currency
  4. TAmt = 0
  5. For i = 1 To Grd.Rows - 1
  6. TAmt = TAmt + Val(Grd.TextMatrix(i, 7))
  7. Next
  8. TAmt = Val(txtBudget.Text) - TAmt
  9. txtBalance.Text = Format(TAmt, "0.00")
  10. End Sub

Hope you can guide me, how to link the txtBudget value in these Form 1 and Form 2. Do I need to use module, or database otherwise? But how it is? I had reviewed the book and hardly thought about it, but I can’t find the answer..
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Linking the text value from different forms

 
1
  #2
Jan 24th, 2009
I'm pretty sure the only way is to refer to the object and assign it directly. That is, something along the lines of:
  1. form2.txtBudget.text = form1.txtBudget.text
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 28
Reputation: nor_d83 is an unknown quantity at this point 
Solved Threads: 0
nor_d83 nor_d83 is offline Offline
Light Poster

Re: Linking the text value from different forms

 
0
  #3
Jan 27th, 2009
Thanx bro for your useful info. It works well, that i used code as below, modifying the code u gave.

In form 1
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub cmdConfirm_Click()
  2. Dim Budget08 As Currency
  3. Budget08 = TextBudget08.Text
  4. Form1.Label11.Caption = Budget08
  5. Form2.TextBudget08.Text = Budget08
  6. End Sub

In form2
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub cmdCalculate_Click()
  2. Dim i As Integer
  3. Dim TAmt As Currency
  4. TAmt = 0
  5. For i = 1 To Grd.Rows - 1
  6. TAmt = TAmt + Val(Grd.TextMatrix(i, 7))
  7. Next
  8. TAmt = Val(TextStat08.Text) - TAmt
  9. txtBalance.Text = Format(TAmt, "0.00")
  10. End Sub

But, the problem is...it doesn't save the amount that i key in for the next usage, that i have to re-key in the budget amount everytime i use the system. Should i need to store the annual budget amount (from form 1) in a database, then put the second Data, (Data2) on the form 2? But how's the code to link the budget amount from the certain table in the database, to the calculation code in the form 2, so that when i click the cmdCalculate, it can show the balance in the txtBalance? Plz bro, help me..
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 28
Reputation: nor_d83 is an unknown quantity at this point 
Solved Threads: 0
nor_d83 nor_d83 is offline Offline
Light Poster

Re: Linking the text value from different forms

 
0
  #4
Jan 30th, 2009
Ok, i've got the answer.. It's just about to link the TextBudget08 on each forms to the sama database.. It's that easy.. Hehe..
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
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