Dim dic As New Dictionary(Of String, Integer) dic.add("A",10) dic.add("B",8) dic.add("C",6) dic.add("D",1) Dim STR As String= 0 For Each dr As DataRow In DataTables("表A").DataRows STR += dic(dr("评分")) Next STR = STR/DataTables("表A").DataRows.Count Dim s As String If STR < 2 AndAlso STR > 0 Then S= "D-" Else If STR >=2 AndAlso STR < 4 Then S= "D" Else If STR >=4 AndAlso STR < 5 Then S="C-" Else If STR >=5 AndAlso STR < 7 Then S="C" Else If STR >=7 AndAlso STR < 8 Then S="B-" Else If STR >=8 AndAlso STR < 9 Then S="B" Else If STR >=9 AndAlso STR <= 10 Then S="A" End If msgbox(S)
|