Hello to all. I have a project which is scheduling system using vb6. I can't or don't know how to find the time conflicts of each subject at the given day and given professor. For example user select the section name then a combo box for selection of subject then the a 5 checkbox(array) will unlocked then the user will select from monday - friday checkbox(array) then the combo box for the selection of start time will unlocked then another combo box for the selection of end time will unlocked and the last one is the combo box for the selection of the professor. I hope you can help me. thank you in advance.
qulit 0 Newbie Poster
yello 3 Light Poster
Exactly what do you want to know? :confused:
You want help on how to do something in vbcode? or you want somebody to implement all your business logic in vbcode?
qulit 0 Newbie Poster
Exactly what do you want to know? :confused:
You want help on how to do something in vbcode? or you want somebody to implement all your business logic in vbcode?
I want some tips or maybe some codes to be able to make the detect the conflicts of each subjects in one section. I don't know the this function or the logic of this.
qulit 0 Newbie Poster
I already done the part of combo box where the user can select subject and professor. The only problem i had is the check box(array) of the day and the combo boxes for the time start and time end which is definitely the available time start and time end will show or can be selected.
hopalongcassidy 35 Junior Poster
You are focusing on the user interface. Have you given any thought to the database? You need a table that describes each time period each professor is teaching a subject and what section that class is in. To find out if a given subject is being taught at a given time, you need something like:
SELECT * from classes WHERE (myStartTime BETWEEN classes.StartTime AND classes.EndTime) AND (myEndTime BETWEEN classes.StartTime AND classes.EndTime)
Hoppy
qulit 0 Newbie Poster
You are focusing on the user interface. Have you given any thought to the database? You need a table that describes each time period each professor is teaching a subject and what section that class is in. To find out if a given subject is being taught at a given time, you need something like:
SELECT * from classes WHERE (myStartTime BETWEEN classes.StartTime AND classes.EndTime) AND (myEndTime BETWEEN classes.StartTime AND classes.EndTime)
Hoppy
I have a screen shot of my program and the codes of the screen shot. pls help me to solve my problem.
qulit 0 Newbie Poster
this the screen shot and the code i use in this form
Option Explicit
Private rs1 As New ADODB.Recordset, rs2 As New ADODB.Recordset, rs3 As New ADODB.Recordset, rs4 As New ADODB.Recordset
Private Sub cbo_subj_Click()
Dim i As Integer
For i = 0 To Check.UBound
Check(i).Enabled = True
Next i
End Sub
Private Sub Check_Click(Index As Integer)
cbo_start.Locked = False
Static sql As String, i As Integer, h As Integer, m As Integer
For i = 0 To Check.UBound
If Check(i).Value Then
cbo_start.Enabled = True
Exit For
ElseIf i = Check.UBound Then
cbo_start.Enabled = False
End If
Next i
If Len(sql) = 0 Then
sql = "SELECT * FROM schedule WHERE idsec = '" & frmselsec.ListView1.SelectedItem & "'" & _
" AND day = '" & Check(Index).Caption & "'"
Else
sql = sql & " OR day = '" & Check(Index).Caption & "'"
End If
Call rs_open(rs2, sql)
If Not rs2.EOF And Not rs2.BOF Then
For h = 7 To 18
Do Until rs2.EOF
For m = 0 To 60 Step 10
If m <> 60 And h & ":" & m <> rs2("start") Then
If m = 0 Then
cbo_start.AddItem h & ":0" & m
Else
cbo_start.AddItem h & ":" & m
End If
End If
Next m
rs2.MoveNext
Loop
rs2.MoveFirst
Next h
Else
For h = 7 To 18
If h = 18 Then
cbo_start.AddItem h & ":00"
Exit For
End If
For m = 0 To 60 Step 10
If m <> 60 Then
If m = 0 Then
cbo_start.AddItem h & ":0" & m
Else
cbo_start.AddItem h & ":" & m
End If
End If
Next m
Next h
End If
End Sub
Private Sub Form_Load()
Call rs_open(rs4, "SELECT * FROM section WHERE idsec = '" & frmselsec.ListView1.SelectedItem & "'")
Me.Caption = rs4("secname")
Call rs_open(rs3, "SELECT * FROM schedule WHERE idsec = '" & rs4("idsec") & "'")
Call rs_open(rs1, "SELECT * FROM subject WHERE idsubj = '" & rs3("idsubj") & "'")
Do Until rs1.EOF
cbo_subj.AddItem rs1("subjname")
rs1.MoveNext
Loop
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With lbl_save
.ForeColor = "&H00800000"
.BackStyle = 0
End With
With lbl_exit
.ForeColor = "&H00800000"
.BackStyle = 0
End With
End Sub
Private Sub lbl_exit_Click()
Me.Enabled = False
Unload Me
With frmSchedmain
.Show
.Enabled = True
End With
rs3.CancelUpdate
End Sub
Private Sub lbl_exit_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With lbl_save
.ForeColor = "&H00800000"
.BackStyle = 0
End With
With lbl_exit
.ForeColor = "&H8000000F"
.BackStyle = 1
End With
End Sub
Private Sub lbl_save_Click()
rs3("idsubj") = cbo_subj.Text
rs3("day") = Check(1).Caption
rs3("start") = cbo_start.Text
rs3("end") = cbo_end.Text
rs3("idprof") = cbo_prof.Text
rs3.Update
frmSchedmain.Visible = True
Unload Me
End Sub
Private Sub lbl_save_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With lbl_save
.ForeColor = "&H8000000F"
.BackStyle = 1
End With
With lbl_exit
.ForeColor = "&H00800000"
.BackStyle = 0
End With
End Sub
This attachment is potentially unsafe to open. It may be an executable that is capable of making changes to your file system, or it may require specific software to open. Use caution and only open this attachment if you are comfortable working with x-ms-bmp files.
hopalongcassidy 35 Junior Poster
I looked at your screen shot and I looked at your code. I also looked at the answer you gave to Yello's question.
From my look at the screen shot, it seems to me that you have not really thought the problem through. Your answer to Yello's question seems to indicate that you want to populate the "Time start", "Time end" and "Professor" comboboxes based on the chosen "Subject" and "Time Day". The problem with this is that the start times, end times and professors are not independent of each other. The combo boxes you have set up to enable a user to select each of these independently. So, for example the user could easily select the start time from one class, the end time for some other class and the professor teaching a third class. I don't think that this will work the way you want it to. I would suggest a single combo box with three columns that lists the actual valid combinations of professor, start time and end time for a given subject and day of the week. Also, when I was going to school, a typical class might be taught by a given professor for an hour on Monday, an hour on Wednesday and an hour on Friday. Is this the case in your school?
I think that you need to think a little bit more about what the possibilities are and how to design your application in such a way that it is impossible for the user to enter invalid data. You should not write a single line of code until your design is absolutely air-tight! Once you have a good design, you will be surprised at how much simpler your code will be.
Hoppy
qulit 0 Newbie Poster
I looked at your screen shot and I looked at your code. I also looked at the answer you gave to Yello's question.
From my look at the screen shot, it seems to me that you have not really thought the problem through. Your answer to Yello's question seems to indicate that you want to populate the "Time start", "Time end" and "Professor" comboboxes based on the chosen "Subject" and "Time Day". The problem with this is that the start times, end times and professors are not independent of each other. The combo boxes you have set up to enable a user to select each of these independently. So, for example the user could easily select the start time from one class, the end time for some other class and the professor teaching a third class. I don't think that this will work the way you want it to. I would suggest a single combo box with three columns that lists the actual valid combinations of professor, start time and end time for a given subject and day of the week. Also, when I was going to school, a typical class might be taught by a given professor for an hour on Monday, an hour on Wednesday and an hour on Friday. Is this the case in your school?
I think that you need to think a little bit more about what the possibilities are and how to design your application in such a way that it is impossible for the user to enter invalid data. You should not write a single line of code until your design is absolutely air-tight! Once you have a good design, you will be surprised at how much simpler your code will be.
Hoppy
Maybe your right. But your suggesting me of thing that i don't understand yet and i don't have enough time to study and go back to design. How bout i populate all the time(from 7:00 am - 5:00 pm) then when user update the system will prompt if the given day and time has a conflict.
hopalongcassidy 35 Junior Poster
Maybe your right. But your suggesting me of thing that i don't understand yet and i don't have enough time to study and go back to design. How bout i populate all the time(from 7:00 am - 5:00 pm) then when user update the system will prompt if the given day and time has a conflict.
Coming up with a good design doesn't take as much time as you imagine. And it's the most important skill you can have as a programmer. And it's much more important than "coming up with something" on this particular assignment in this particular class. Better to fail on an assignment than to fail in your career. You can ask anyone who has achieved success at anything and they will (without exception) tell you that what I'm saying is true. In your heart, you already know it's true.
You need to look at each element of the data you want the user to input and ask yourself, "What am I expecting the user to input?" and "What other things might the user input that will create problems?" and then "How can I change my design to eliminate the problems?".
Then, when you go to write the code, you will find that there are a lot of conditions that you don't have to write code to check for because you will have designed the possibility of those conditions out of the software. Your code will be simpler, easier to write and debug and easier for someone else to read.
Hoppy
qulit 0 Newbie Poster
Coming up with a good design doesn't take as much time as you imagine. And it's the most important skill you can have as a programmer. And it's much more important than "coming up with something" on this particular assignment in this particular class. Better to fail on an assignment than to fail in your career. You can ask anyone who has achieved success at anything and they will (without exception) tell you that what I'm saying is true. In your heart, you already know it's true.
You need to look at each element of the data you want the user to input and ask yourself, "What am I expecting the user to input?" and "What other things might the user input that will create problems?" and then "How can I change my design to eliminate the problems?".
Then, when you go to write the code, you will find that there are a lot of conditions that you don't have to write code to check for because you will have designed the possibility of those conditions out of the software. Your code will be simpler, easier to write and debug and easier for someone else to read.
Hoppy
I guest your right. I'll start redesign this form. You say earlier that combo box can have more than 1 fields(start time, end time, and professor) or what ever the name of that. Can you tell me how to do it.
hopalongcassidy 35 Junior Poster
Yes,
1. Create a ListBox on your form.
2. Open the Properties Box and click on the "Data" tab.
3. For the "Row Source Type", specify "Table/Query".
4. For the "Row Source" enter the name of the table or query you want to use to provide the data to populate the ListBox. In your case, you are probably want to use a query since you only want to display the table entries that correspond to the subject that the user chooses and the day of the week the user chooses. The query should probably have an "ORDER BY StartTime" clause in it. This way it will be easier for a student to pick a class that occurs at a convenient time.
5.For "Bound Column", enter the column number in the query that corresponds to "Start Time".
6. Click on the "Format" tab.
7. Enter the "Column Count".
8. For "Column Heads" select "Yes". This will cause the ListBox to display the field names in the query as the column headings.
9. For "Column Widths", you are going to have to experiment a little. The "Column Widths" property consists of numbers separated by semicolons (;). There should be as many widths as you specified in "Column Count". Make sure that the sum of the column widths does not exceed the width of the ListBox.
10. Click on the "Other" tab and enter the name of the ListBox as you will refer to it in your code.
That's it.
Hoppy
qulit 0 Newbie Poster
Yes,
1. Create a ListBox on your form.
2. Open the Properties Box and click on the "Data" tab.
3. For the "Row Source Type", specify "Table/Query".
4. For the "Row Source" enter the name of the table or query you want to use to provide the data to populate the ListBox. In your case, you are probably want to use a query since you only want to display the table entries that correspond to the subject that the user chooses and the day of the week the user chooses. The query should probably have an "ORDER BY StartTime" clause in it. This way it will be easier for a student to pick a class that occurs at a convenient time.
5.For "Bound Column", enter the column number in the query that corresponds to "Start Time".
6. Click on the "Format" tab.
7. Enter the "Column Count".
8. For "Column Heads" select "Yes". This will cause the ListBox to display the field names in the query as the column headings.
9. For "Column Widths", you are going to have to experiment a little. The "Column Widths" property consists of numbers separated by semicolons (;). There should be as many widths as you specified in "Column Count". Make sure that the sum of the column widths does not exceed the width of the ListBox.
10. Click on the "Other" tab and enter the name of the ListBox as you will refer to it in your code.That's it.
Hoppy
Thank you for the help. I'll follow what you said. Can I have your email address so I can directly ask you or something? And I'm sorry, I'm just a new on this field. Thank you again and good luck.:)
hopalongcassidy 35 Junior Poster
Thank you for the help. I'll follow what you said. Can I have your email address so I can directly ask you or something? And I'm sorry, I'm just a new on this field. Thank you again and good luck.:)
I'm sorry, but I think it's against the DaniWeb rules to do that. If you just click on my name in this or any other thread in which I have participated, you will get a dropdown box. Click on "Send a private message". I think it will accomplish the same thing.
Hoppy
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.