Substraction code in MSFlex Grid

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

Substraction code in MSFlex Grid

 
0
  #1
Jan 7th, 2009
Hello there,
I am doing my 'budget control system', and I want to make substraction from the value i entered in a textbox (budget for the year), with the sum of all the value in the 8th column of the MS Flex Grid data (which is the money used).

Can anybody plz guide me how to make it?
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 509
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 88
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: Substraction code in MSFlex Grid

 
0
  #2
Jan 7th, 2009
Hi,

Use MSFlexGrid.TextMatrix ( row, column ) to get/set then value rom/to the grid.
KSG
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: Substraction code in MSFlex Grid

 
1
  #3
Jan 7th, 2009
Hi,

Try This :

  1. Dim i As Integer
  2. Dim TAmt As Currency
  3. TAmt = 0
  4. For i = 1 To Grd.Rows-1
  5. TAmt = TAmt + Val(Grd.TextMatrix(i, 8))
  6. Next
  7. TAmt = TAmt +Val(txtBudget.Text)
  8. MsgBox "Total Amount Is : " & Format(TAmt, "0.00")

Change names of your controls, and Column accordingly..

REgards
Veena
Last edited by QVeen72; Jan 7th, 2009 at 11:39 pm.
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: Substraction code in MSFlex Grid

 
0
  #4
Jan 8th, 2009
Actually, I'm using FlexGrid to display the budget database records. I've tried the codes given by Veena, but it displays the 424 error, and debug at the line below..

For i = 1 To Grd.Rows-1

Could both of you plz explain me, with more details? Or by giving me codes to be applied.. Plz..
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: Substraction code in MSFlex Grid

 
0
  #5
Jan 8th, 2009
How about you rename your FlexGrid control to Grd..... (or is it already Grd)?
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: Substraction code in MSFlex Grid

 
0
  #6
Jan 9th, 2009
Thank you Comatose,
After i rename it to Grd, the error disappear..
But still, i can't figure out how can it works..
What if my plan being like this..
I have to put first, the value of budget in the txtBudget..
Then, the value in the txtBudget will be reduced by every value in the Grd 8th column..
Then, the balance will be appear in the txtBalance..
Could anybody from 3 of you, tell me the codes to make it work? Sorry if i'm like asking, but i am a beginner VB user..
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: Substraction code in MSFlex Grid

 
1
  #7
Jan 9th, 2009
Hi,

Yes, Little bit tweaking of my code, will do the job:

  1. Dim i As Integer
  2. Dim TAmt As Currency
  3. TAmt = 0
  4. For i = 1 To Grd.Rows-1
  5. TAmt = TAmt + Val(Grd.TextMatrix(i, 8))
  6. Next
  7. TAmt = Val(txtBudget.Text) - TAmt
  8. txtBalance.Text = Format(Tamt,"0.00")

You can Call this In LostFocus Of txtBudget..

Regards
Veena
Last edited by QVeen72; Jan 9th, 2009 at 2:29 am.
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: Substraction code in MSFlex Grid

 
0
  #8
Jan 9th, 2009
Sorry... But, it didn't work.. Maybe, because i don't know how and where to use it.. I copied and pasted the latest codes by Venna in the private Sub Grd_Click like below..
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub Grd_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, 8))
  7. Next
  8. TAmt = Val(txtBudget.Text) - TAmt
  9. txtBalance.Text = Format(TAmt, "0.00")
  10. End Sub
Did i use it incorrectly? Here i enclosed a small-sized of the related form, to show u what i'm doing..

P/S: Do i need to put codes also in the txtBudget and txtBalance? Sorry for the dumb question...
Last edited by Narue; Jan 10th, 2009 at 9:33 pm. Reason: added code tags
Attached Files
File Type: zip sample.zip (14.1 KB, 13 views)
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: Substraction code in MSFlex Grid

 
0
  #9
Jan 11th, 2009
Plz sumbody.... Plz tell me, how to use the codes Venna gave me.. I really don't have the idea where to put the codes.. FlexGrid is a new thing for me.. It looks come to the solved, but i can't make it.. Plz... I need to pass this project, in order to get my diploma... I'm not an IT student, but doing the IT project..
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: Substraction code in MSFlex Grid

 
0
  #10
Jan 11th, 2009
What if like this... I have to put the budget value first in the txtBudget, then I need to click the cmdCalculate to have the balance calculated being in the txtBalance.... I really need a detail explaination, which codes to put in the FlexGrid, which in the txt and cmd... Plz... I need your kind help... I'm not an IT student, and don't have a good teacher about it.. Only God who knows how to repay your help.. Plz..
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC