Web Hosting, Design, & Coding forum

General discussion

VBScript

by niranalayo / January 24, 2006 7:06 PM PST

Hello everybody,

I am trying to divide students into tutor groups, the number of students in each tutor group must not be more than 20 but can be less than 20. I r=tried to devive an algorithm but it does not fully work. e.g for 75 students it is giving me 3 groups instead of 4. This is the code I have. Is there anything wrong with it?

Private Sub Tutor_Group_no_Click()
Dim NoG, NoS
Dim rstut As New ADODB.Recordset
rstut.Open ("select * from tblTutor_Group"), CurrentProject.Connection, adOpenKeyset, adLockOptimistic

NoS = DCount("Student_Id", "Query_Computing_and_Information_Systems")

NoG = 1

Do Until (NoS / NoG) <= 20

If (NoS / NoG) > 20 Then
NoG = NoG + 1
rstut.AddNew
rstut("Course_Id") = 1
rstut.Update
End If

Loop

MsgBox "Done"

End Sub

Please can anybody help ?

Discussion is locked
You are posting a reply to: VBScript
The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our CNET Forums policies for details. All submitted content is subject to our Terms of Use.
Track this discussion and email me when there are updates

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

You are reporting the following post: VBScript
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Collapse -
Re: VBScript
by Kees Bakker / January 25, 2006 5:30 PM PST
In reply to: VBScript

Niranalayo,

Let's follow the code.

You state about the number of groups. That seems like NoG, but it isn't. As an example, take a situation with 2 students. Coding starts with NoG = 1. Until-oop is executed at least once. If-condition, however, isn't true: 2/1 = 2 < 20. So NoG stays 1 and there is no record put into the recordset. But there is a group. In fact, there seems to always be one record less than the value of NoG. The solution could be to write one record outside the loop. Unless, of course, NoS = 0: no students, no group. Your current code doesn't make a difference between 0 and 1, and that seems wrong to me.

Seems like you have to redo the logic a little bit.


Hope this helps.


Kees

Collapse -
VB
by niranalayo / January 25, 2006 10:26 PM PST
In reply to: Re: VBScript

Thanks kees for the tip, I am quite new to VB and I cant think of any logic to apply can u help?

Thank you 4 your response,I am thinking about what u have suggested and will be trying it out.

Collapse -
(NT) (NT) Elementary math: NoG = integer ((NoS + 19) / 20)
by Kees Bakker / January 27, 2006 2:53 AM PST
In reply to: VB
Collapse -
Thanks a Million !!!
by niranalayo / January 27, 2006 6:52 PM PST

Thanks very much. i did not think of it that way. You are a saver. i cant believe it could be that simple.I guess you are a very good thinker.

Cheers and once again,

Thank you.

Collapse -
(NT) (NT) You're welcome.
by Kees Bakker / January 28, 2006 8:55 PM PST
In reply to: Thanks a Million !!!

Popular Forums

icon
Computer Newbies 10,686 discussions
icon
Computer Help 54,365 discussions
icon
Laptops 21,181 discussions
icon
Networking & Wireless 16,313 discussions
icon
Phones 17,137 discussions
icon
Security 31,287 discussions
icon
TVs & Home Theaters 22,101 discussions
icon
Windows 7 8,164 discussions
icon
Windows 10 2,657 discussions

FALL TV PREMIERES

Your favorite shows are back!

Don’t miss your dramas, sitcoms and reality shows. Find out when and where they’re airing!