943,671 Members | Top Members by Rank

Ad:
Jan 24th, 2009
0

Linking the text value from different forms

Expand Post »
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..
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
nor_d83 is offline Offline
28 posts
since Aug 2008
Jan 24th, 2009
1

Re: Linking the text value from different forms

I'm pretty sure the only way is to refer to the object and assign it directly. That is, something along the lines of:
vb Syntax (Toggle Plain Text)
  1. form2.txtBudget.text = form1.txtBudget.text
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jan 27th, 2009
0

Re: Linking the text value from different forms

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..
Reputation Points: 10
Solved Threads: 0
Light Poster
nor_d83 is offline Offline
28 posts
since Aug 2008
Jan 30th, 2009
0

Re: Linking the text value from different forms

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..
Reputation Points: 10
Solved Threads: 0
Light Poster
nor_d83 is offline Offline
28 posts
since Aug 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: EXCEL VBA reporting in a target file
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: printer layout problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC