DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Visual Basic 4 / 5 / 6 (http://www.daniweb.com/forums/forum4.html)
-   -   Substraction code in MSFlex Grid (http://www.daniweb.com/forums/thread166879.html)

nor_d83 Jan 7th, 2009 6:21 pm
Substraction code in MSFlex Grid
 
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?

selvaganapathy Jan 7th, 2009 10:13 pm
Re: Substraction code in MSFlex Grid
 
Hi,

Use MSFlexGrid.TextMatrix ( row, column ) to get/set then value rom/to the grid.

QVeen72 Jan 7th, 2009 11:38 pm
Re: Substraction code in MSFlex Grid
 
Hi,

Try This :

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

Change names of your controls, and Column accordingly..

REgards
Veena

nor_d83 Jan 8th, 2009 5:24 pm
Re: Substraction code in MSFlex Grid
 
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..

Comatose Jan 8th, 2009 10:17 pm
Re: Substraction code in MSFlex Grid
 
How about you rename your FlexGrid control to Grd..... (or is it already Grd)?

nor_d83 Jan 9th, 2009 1:43 am
Re: Substraction code in MSFlex Grid
 
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..

QVeen72 Jan 9th, 2009 2:29 am
Re: Substraction code in MSFlex Grid
 
Hi,

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

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

You can Call this In LostFocus Of txtBudget..

Regards
Veena

nor_d83 Jan 9th, 2009 6:55 pm
Re: Substraction code in MSFlex Grid
 
1 Attachment(s)
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..
Private Sub Grd_Click()
Dim i As Integer
      Dim TAmt As Currency
      TAmt = 0
      For i = 1 To Grd.Rows - 1
        TAmt = TAmt + Val(Grd.TextMatrix(i, 8))
      Next
      TAmt = Val(txtBudget.Text) - TAmt
      txtBalance.Text = Format(TAmt, "0.00")
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...

nor_d83 Jan 11th, 2009 6:07 pm
Re: Substraction code in MSFlex Grid
 
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..

nor_d83 Jan 11th, 2009 6:14 pm
Re: Substraction code in MSFlex Grid
 
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..


All times are GMT -4. The time now is 4:41 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC