Home > Software engineering >  Vb production arrangement system, but the algorithm part do not understand, please explain, thank yo
Vb production arrangement system, but the algorithm part do not understand, please explain, thank yo

Time:10-08

Private Sub PKZX ()
'the Second (Time)
'On Error GoTo finish
Dim weizi, x, y, j1, j2 As Integer
Bubble sort YuPK 'space method
The Set kc4=CNN. The Execute (" select * from spatial detail the order by the remaining space asc ")
Do While Not kc4. EOF 'when there is no pointer to the end of file, continue to cycle, and once a pointer to the file at the end, then stop circulation,
For hang=1 To Grid1. Rows - 1
If Grid1. Cell (hang, 1). The Text=kc4. Fields (0) Then
The Exit For 'Exit For loop
End the If
Gridcs' execution process, this process is mainly run array, read the teacher resources and the class of the available resources in
Grid4hq 'here is compare teacher resources and the class of the available resources, it is concluded that the result of the need to
If Grid04. Rows & lt;=1 Then
The Set kc4=CNN. The Execute (" delete * details from space ")
MsgBox "the system have unpredictable trouble when the generation schedule, please check the setting, and cancellation of the curriculum to regenerate!"
GoTo 1
End the If
'course of proper position is obtained by comparing the
Dim Gint (7) As an Integer 'access to the current course each day space
Dim Statint (7) As an Integer 'store every day the first value
For I=0 To 6
Gint (I)=0
Statint (I)=0
Next
Dim MXstr () As the Integer 'subsidiary array
'MXstr=Split (kc4. Fields (2), ";" )
For I=1 To Grid4. Rows - 1
Dim MXInt As Integer
MXInt=Round (Grid4. Cell (I, 1). The Text/nknumber)
If MXInt & lt; Grid4. Cell (I, 1). The Text/nknumber Then
MXInt=MXInt + 1
End the If
Select Case MXInt 'access to the distribution of every day
Case 1
Gint (0)=Gint (0) + 1
If Statint (0)=0 Then
Statint (0)=Grid4. Cell (I, 1). The Text
End the If
Case 2
=Gint Gint (1) (1) + 1
If Statint (1)=0 Then
Statint (1)=Grid4. Cell (I, 1). The Text
End the If
Case 3
=Gint Gint (2) (2) + 1
If Statint (2)=0 Then
Statint. (2)=Grid4 Cell (I, 1). The Text
End the If
Case 4
=Gint Gint (3) and (3) + 1
If Statint (3)=0 Then
Statint. (3)=Grid4 Cell (I, 1). The Text
End the If
Case 5
Gint (4)=Gint (4) + 1
If Statint (4)=0 Then
Statint. (4)=Grid4 Cell (I, 1). The Text
End the If
Case 6
Gint (5)=Gint (5) + 1
If Statint (5)=0 Then
Statint. (5)=Grid4 Cell (I, 1). The Text
End the If
Case 7
Gint (6)=Gint (6) + 1
If Statint (6)=0 Then
Statint (6)=Grid4. Cell (I, 1). The Text
End the If
End the Select
Next
'-- -- -- -- -- -- -- -- -- -- this section is the distribution results sorting
For I=0 To 6
The Set kc5=CNN. Execute (" insert into I values (" & amp; Gint (I) & amp; ", "& amp; Statint (I) & amp; ") ")
Next
The Set kc5=CNN. The Execute (" select * from I order by desc "I)
For I=0 To 6
Gint (I)=kc5. Fields (0)
Statint (I)=kc5. Fields (1)
Kc5. MoveNext
Next
Set kc5=CNN. The Execute (" delete * from I ")
'-- -- -- -- -- -- -- -- -- -- --
'-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --


'-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
For I=1 To Grid1. Cell (hang, 3). The Text/n 'through the cycle For a course began To row table
Weizi=Statint (I - 1) 'column is equal to the maximum, equivalent to the average distribution
'the following calculating the value of the random out orientation in the course have a line a list
X=Round (weizi/nknumber)
If x & lt; Weizi/nknumber Then
X=x + 1
End the If
Y=weizi Mod nknumber 'Mod is two Numbers by the remainder return
If y=0 Then
If nknumber & lt;> 7 Then
Y=nknumber - 1
The Else
Y=nknumber
End the If
End the If
The Select Case n
Case 1
Grid5. Cell (y, x). The Text=Grid1. Cell (hang, 1). The Text
Array1 (weizi)="1"
Array2 (weizi)="1"
XPPbr1. Value=https://bbs.csdn.net/topics/XPPbr1.Value + 1
End the Select
'more than XX="1" part is real time to modify form, so that later will form the data submitted to the database
Dim gsql1, gsql2 As String
Gsql1=""
Gsql2=""
For j1=1 To nknumber * 7 'here is start To submit the form data
If array1 (j1)="" Then
Gsql1=gsql1 & amp; "0"
The Else
Gsql1=gsql1 & amp; Array1 (j1)
End the If
Next
Set kc2=CNN. Execute (" update takes up the Set takes up='" & amp; Gsql1 & amp; "' where teachers name=" & amp; Grid1. Cell (hang, 5). The Text & amp; "'")
'will modify the data submitted to the database
For j2=1 To nknumber * 7
If array2 (j2)="" Then
Gsql2=gsql2 & amp; "0"
The Else
Gsql2=gsql2 & amp; Array2 (j2)
End the If
Next
Set kc2=CNN. Execute (" update course takes up the Set to take up='" & amp; Gsql2 & amp; "' where class=" & amp; XPCombo1. Text & amp; "'")
Next
End the If
Kc4. MoveNext
Loop
1:
Dim gsql3 As String
For I=1 To Grid5. Rows - 1 'here is will produce schedule is saved To the database
Gsql3="insert into a temporary table generated (time, on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday, belongs to the class) values ('
"For j=0 To Grid5 Cols - 1
Gsql3=gsql3 & amp; Grid5. Cell (I, j) Text & amp; "', '
"Next
Gsql3=gsql3 & amp; XPCombo1. Text & amp; "')
"The Set ventilation=CNN. The Execute (gsql3)
Next
'add a corresponding teaching table
For I=1 To Grid5. Rows - 1 'here is will produce schedule is saved To the database
Teachers gsql3="insert into corresponding tables (period, one, two, three, four, five, six, day, class) values ('
"Gsql3=gsql3 & amp; Grid5. Cell (I, 0). The Text & amp; "', '
"For j=1 To Grid5 Cols - 1
For k=0 To Grid1. Rows 1
If Grid5. Cell (I, j) Text="" And k=Grid1. Then Rows - 1
Gsql3=gsql3 & amp; "', '
"The Else
If Grid1. Cell (k, 1). The Text=Grid5. The Cell (I, j) Text Then
Gsql3=gsql3 & amp; Grid1. Cell (k, 5). The Text & amp; "', '
"End the If
End the If
Next
Next
Gsql3=gsql3 & amp; XPCombo1. Text & amp; "')
"The Set ventilation=CNN. The Execute (gsql3)

Next

The Exit Sub
'finish:
'MsgBox Err. The Description
End Sub
  •  Tags:  
  • VBA
  • Related