下面这段代码分组顺序不同,表显示的结果不同,能否简化这段程序,实现按照选择的次序(可能先选性别再选民族,也有可能也选民族再选性别)进行分组
Dim cmbt1 As String = cmb1.SelectedText
Dim cmbt2 As String = cmb2.SelectedText
Dim cmbt3 As String = cmb3.SelectedText
Dim cmbt4 As String = cmb4.SelectedText
Dim cmbt5 As String = cmb5.SelectedText
Dim sg As New GroupTableBuilder("T分dj",datatables("统考dj"))
Select Case cmbt1 '范围
Case "区"
sg.Groups.AddDef("qx") '根据区县分组
Case "校"
sg.Groups.AddDef("qx") '
sg.Groups.AddDef("xx") '根据学校分组
Case "师"
sg.Groups.AddDef("qx") '
sg.Groups.AddDef("xx") '
sg.Groups.AddDef("jx") '根据教师分组
End Select
Select Case cmbt5
Case "类别-民族-性别"
If cmbt2 = "是" Then
sg.Groups.AddDef("lb") '根据类别分组
End If
If cmbt3 = "是" Then
sg.Groups.AddDef("mz") '根据民族分组
End If
If cmbt4 = "是" Then
sg.Groups.AddDef("xb") '根据性别分组
End If
Case "类别-性别-民族"
If cmbt2 = "是" Then
sg.Groups.AddDef("lb") '根据类别分组
End If
If cmbt4 = "是" Then
sg.Groups.AddDef("xb") '根据性别分组
End If
If cmbt3 = "是" Then
sg.Groups.AddDef("mz") '根据民族分组
End If
Case "性别-类别-民族"
If cmbt4 = "是" Then
sg.Groups.AddDef("xb") '根据性别分组
End If
If cmbt2 = "是" Then
sg.Groups.AddDef("lb") '根据类别分组
End If
If cmbt3 = "是" Then
sg.Groups.AddDef("mz") '根据民族分组
End If
Case "性别-民族-类别"
If cmbt4 = "是" Then
sg.Groups.AddDef("xb") '根据性别分组
End If
If cmbt3 = "是" Then
sg.Groups.AddDef("mz") '根据民族分组
End If
If cmbt2 = "是" Then
sg.Groups.AddDef("lb") '根据类别分组
End If
Case "民族-类别-性别"
If cmbt3 = "是" Then
sg.Groups.AddDef("mz") '根据民族分组
End If
If cmbt2 = "是" Then
sg.Groups.AddDef("lb") '根据类别分组
End If
If cmbt4 = "是" Then
sg.Groups.AddDef("xb") '根据性别分组
End If
Case "民族-性别-类别"
If cmbt3 = "是" Then
sg.Groups.AddDef("mz") '根据民族分组
End If
If cmbt4 = "是" Then
sg.Groups.AddDef("xb") '根据性别分组
End If
If cmbt2 = "是" Then
sg.Groups.AddDef("lb") '根据类别分组
End If
End Select
Tables("T分综合分析_table1").DataSource = DataTables("T分dj")
[此贴子已经被作者于2016/3/5 11:59:54编辑过]