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

Are you using Database for ur application ? if yes which database are u using?

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

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.