hey all,

i got problem about count method. for example, there are three students(a,b,c), and there are two courses(coure1,course2), then student a and b enrol course1, and student c enrol course 2. i need to count how many students enrolled course1.

Public Function numStudents() As Integer
        'return number of students enrolled in this course 

        Return myEnrols.Count
    End Function

so how to write this function.thank you very much.

The question is: how do you store the courses for students?
like does every student have a property list(of courses)?

yes. when students enrol course1, i need to count how many students enrolled course1.
how to store the courses for students, and how to count how many students enrolled this course. like, there are three students enrolled course1, the function should reture 3(because there are 3 students enrolled this course). how to do this?
thanks

What database?

If MS SQL, you can simply use the below query

Dim StringCount as string = "SELECT COUNT from CourseEnrolled where Course_ID IN (csc01,csc02,csc03)"

What database?

If MS SQL, you can simply use the below query

Dim StringCount as string = "SELECT COUNT from CourseEnrolled where Course_ID IN (csc01,csc02,csc03)"

Did you mean

select count(*) from CourseEnrolled where Course_ID = 'csc01'

?

Did you mean

select count(*) from CourseEnrolled where Course_ID = 'csc01'

?

thanks for the code edit. Missed the wildcard

Edited 5 Years Ago by Netcode: n/a

This article has been dead for over six months. Start a new discussion instead.