Hi guys,

Can any help me i had a peoblem please just give me idea.

I want to calculate the share of a teacher let me explain how

1.if a teacher teaching three subjects in 10th class and three subjects in 9th
2.i have to calculate 50% of the fee paid by every student and want to calculate total share of teacher please help me.

Recommended Answers

All 21 Replies

I am a bit confused. If a teacher teaches more than one subject, you want to split the student fee to the amount of classes he teaches?

Where does the 50% come from?

Ok can we calculate it for one subject for a teacher then for second subjects then for third subject at the end we should have total amount or if you have any idea then please tell me??

I will try and figure out what you need.

Student fee is $1000.00 per month
He sees 4 teachers, splitting his fee into $250.00 per teacher
The teacher teaches one subject but with ten students
He receives $2500.00 per month from the student fees.

Is this what you are looking for?

Yes and for other students how can we do this??

Student fee is $1000.00 per month
He sees 4 teachers, splitting his fee into $250.00 per teacher

I'm not sure what you mean by "other" students. In my quote, are we not covering all students? Is there more you need on the student side? If so, what?

For the calculation use the following -

Private Sub Command1_Click()

Dim xStudentFee As Integer
Dim xTotalStudents As Integer

Dim xTeacherFee As Integer
Dim xTotalTeachers As Integer

Dim x As Integer

'Get the amount the student pays per month
xStudentFee = 1000
'Get the total amount of students
xTotalStudents = 10

'Show the total student fees in text box
x = xStudentFee * xTotalStudents
Text1.Text = Format(x, "### ###.00") '$10000.00

'Get the total teachers teaching
xTotalTeachers = 5

'Get the teacher fee. 10 students in a class. 5 teachers.
xTeacherFee = x / xTotalTeachers
Text2.Text = Format(xTeacherFee, "### ###.00")  '$2000.00 per teacher
End Sub

This what you needed?

Ok just a minut i tell you see let us suppose a teacher teaches 50 students ok we want to calculate its share
secondly how we will calculate how many students taught by this teacher?

You can use the above code I supplied to get to your answer for the 50 students per teacher. : 50 students @ $1000.00 each = $50 000.00 in total. Determine how many teachers there are and divide the $50 000.00 into all of them, lets say 10 teachers, then each gets $5 000.00.

Your quote

secondly how we will calculate how many students taught by this teacher

is a duplication, because in the line above you already stated that there is 50 students by the teacher.

It seems that the language is a bit of a barrier here. Use an example as I did so I can determine exactly what you need.

Ok i got it just my last question please tell me how can i calculate total fee paid by all studednts for example value of fee paied stored in databse column FeePaid how would i take sum of dues submit for a specific month like october 2010

The easiest way is to add a field to your table called PaidYesNo. As soon as a student pays his fee, when updating the "receipt", this field will be updated from No to Yes.

Now search your database for all the fees paid in one month (October) where the field 'PaidYesNo' is Yes. To calculate the sum do the following. Only sample code, play around with it until you have what you need.

rsPaid.Open "SELECT * FROM MyTable WHERE DateValue(" & "'" & Date & "' AND PaidYesNo = 'Yes'"

If rsPaid.BOF = True Or rsPaid.EOF =True Then
'No records available
Exit sub
   Else
Dim xCount As Integer, xTotal As Integer

xTotal = 0

For xCount = 0 To rsPaid.RecordCount
   xTotal = xTotal + rsPaid!TheAmountIReceivedFieldName
   rsPaid.MoveNext
Next xCount

Text1.Text = xTotal
commented: Nice example and good advic e :) +34

Should i try this code on click event of button or keypress of textbox

Rather do it in button click event. Remember to add references to ms activex data objects and do the whole connection code as well. The code supplied was only a snippet.

Did this help for you?

ok i got the solution just tell me how would i calculate the sum of paidfee column for specific month.

Look at the code I have already supplied to you in this part -

For xCount = 0 To rsPaid.RecordCount
   xTotal = xTotal + rsPaid!TheAmountIReceivedFieldName
   rsPaid.MoveNext
Next xCount
 
Text1.Text = xTotal

Dear i have tried thiscode for total fee calculation but i got error i think there is a problem with select statement i checked it by debuging this piece of code counts the total no of record but does not fetch record and make their sum please check it.
Thanks in advance for your greate help.

'On Error Resume Next
'Set rs = Nothing
Set rs = db.OpenRecordset("select * from fee where " & "'" & txtdate1 & "'" And "'" & txtdate2 & "'")
Dim xcount As Integer, xtotal As Integer
xtotal = 0
For xcount = 0 To rs.RecordCount
xtotal = xtotal + rs.Fields!totalfee
rs.MoveNext
Next xcount
txttotal.Text = xtotal

No body has any idea?????????

Your select statement is incorrect. The "AND" must form part of the statement.

Set rs = db.OpenRecordset("select * from fee where " & "'" & txtdate1 & "'" And "'" & txtdate2 & "'")

'Do like this -

Set rs = db.OpenRecordset("select * from fee where MyFieldNameHere = DateValue(" & "'" & txtdate1 & "') And MySecondDateFieldNameHere = DateValue(" & "'" & txtdate2 & "')")

Ok the code is now

On Error Resume Next
Set rs = db.OpenRecordset("select * from fee where Paydate = DateValue(" & "'" & txtdate1 & "') And Paydate = DateValue(" & "'" & txtdate2 & "')")
Dim xcount As Integer, xtotal As Integer
xtotal = 0
For xcount = 0 To rs.RecordCount
xtotal = xtotal + rs.Fields!totalfee
rs.MoveNext
Next xcount
txttotal.Text = xtotal

When i enter two dates it just calculate sum of first two value and without entering the two dates when i click on claculation button it calculate the sum of all values present in totalfee column please help me to resolve this problem.

Your problem is still in your select statement. You have entered the same field "PayDate, but with two separate date values. Use the >/</= signs to return the correct values.

Set rs = db.OpenRecordset("select * from fee where Paydate => DateValue(" & "'" & txtdate1 & "')"

If the date or values you want to return is between 2 dates, the following -

Set rs = db.OpenRecordset("select * from fee where Paydate => DateValue(" & "'" & txtdate1 & "') And Paydate <= DateValue(" & "'" & txtdate2 & "')")

I have found the solution i have resolved the problem thanks for your help.

commented: Well done solving this. +4

It was a pleasure. I'm glad that you put in the effort to get the answer and solve it. That is what coding is all about, getting to the bottom of it all.

I gave you some reputation points for your efforts, well done:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.