Dim frm As winform.Form = Forms("窗口2")
Dim y As Integer = frm.Controls("ComboBox1").value '指定年
Dim m As Integer = frm.Controls("ComboBox2").value '指定月
Dim k As Integer = frm.Controls("ComboBox3").value '指定开始位置
Dim k1 As Integer = frm.Controls("ComboBox4").value '指定开始位置
Dim k2 As Integer = frm.Controls("ComboBox5").value '指定开始位置
Dim days As Integer = Date.DaysInMonth(y,m) '返回指定 年\月 的天数
Dim ed As Date = New Date(y,m,Days)
Dim sd As Date = New Date(y,m,1) '从指定日期开始
Dim zblds As List(Of String) = DataTables("值班领导").GetValues("姓名","姓名 is not null", "_sortkey")
Dim dbzs As List(Of String) = DataTables("带班组").GetValues("姓名","姓名 is not null","_sortkey")
Dim zbrys As List(Of String) = DataTables("值班人员").GetValues("姓名","姓名 is not null","_sortkey")
Dim d As Date = sd
Dim i1 As String = iif(k2=0,1,k2)
Dim i2 As Integer = iif(k1=0,1,k1)
Dim i3 As Integer = iif(k=0, 1, k)
Do While d <= ed
Dim nr As Row = Tables("表a").AddNew
nr("日期") = d
nr("星期") = Format(d, "dddd")
nr("值班人员") = zbrys(i3-1)
nr("带班组") = dbzs(i2-1)
nr("值班领导") = zblds(i1-1)
d = d.AddDays(1)
i2 += 1
i3 += 1
If i2 > dbzs.count Then
i2 = 1
End If
If i3 > zbrys.count Then
i3 = 1
End If
If d.DayOfWeek = 0 Then
i1 += 1
End If
If i1 > zblds.count Then
i1 = 1
End If
Loop