If Forms("高考排考室").Controls("NumericComboBox1").Value <= 0 Then
MessageBox.Show("考场号不能小等于零值!","中止操作",MessageBoxButtons.OK,MessageBoxIcon.Exclamation)
Else
Dim f As New Filler
f.SourceTable = DataTables("高考排考室")
f.SourceCols = "班级,姓名"
f.DataTable = DataTables("高考排考室")
f.DataCols = "班级,姓名"
f.ExcludeExistValue = True
f.Fill
For i As Integer = 0 To CurrentTable.rows.count -1
CurrentTable.Rows(i)("索引顺序") = Rand.Next(10000)
Next
CurrentTable.sort = "索引顺序"
For b As Integer = 0 To CurrentTable.rows.count -1
CurrentTable.Rows(b)("考场号") = Format(1 + b Mod e.Form.Controls("NumericComboBox1").Value,"100")
Next
CurrentTable.sort = "索引顺序"
Dim k As Integer = 1
Dim z As Integer = 1
For b As Integer = 0 To CurrentTable.rows.count -1
CurrentTable.Rows(b)("考场号") = Format(k,"100") ''默认Format(k,"000")
CurrentTable.Rows(b)("座位号") = Format(Rand.Next(30) + b Mod e.Form.Controls("NumericComboBox1").Value,"00")
CurrentTable.Rows(b)("座位号") = z
CurrentTable.Rows(b)("座位号") = Format(z,"00")
z = z + 1
If z > 30 Then
z = 1
k = k + 1
End If
Next
End If
蓝老师,这个代码很好用,由于是前面的考场排满30人后,再排后面的考场,这个填入考场数量的"NumericComboBox1"已经没有用了,取消输入考场数量这个代码就更完美了