1

我有学生的成绩和熟练程度。

例如,对于五年级,有四个熟练程度。四个熟练程度对应字母表中的字母,所以如果一个五年级学生的字母分配为 B,那么他的熟练程度将是“低于熟练”,因为 A 到 R 中的任何字母都会得到“低于熟练”的水平“我想知道如何处理案件,

我对代码的粗略想法如下:

Function ConvertScores(Grade, Letter_Score)
Select Case ConvertScore(5, like "[A-R]")
    Case ConvertScore(5, like" 
        ConvertScores = "F & P Remedial"
    Case 2
        ConvertScores = "F & P Below Proficient"
    Case 3
        ConvertScores = "F & P Proficient"
    Case 4
        ConvertScores = "F & P Advanced"



End Function

所以是的,我希望 VBA 有一个列表对象,VBA 中的列表对象是什么?

编辑:我可以使用多个 If 语句来做到这一点,但在我看来,案例会是一个更好的方法。

这是我想用于案例而不是多个 if-thens 的代码

Function ConvertScoresMOY(Grade, Letter_Score) As String
If Grade = "5" And Letter_Score Like "[A-R]" Then
    ConvertScoresMOY = "F & P Remedial"
ElseIf Grade = "5" And Letter_Score Like "[S-T]" Then
    ConvertScoresMOY = "F & P Below Proficient"
ElseIf Grade = "5" And Letter_Score Like "[U-V]" Then
    ConvertScoresMOY = "F & P Proficient"
ElseIf Grade = "5" And Letter_Score Like "[W-Z]" Then
    ConvertScoresMOY = "F & P Advanced"
Else:
End If
End Function
4

2 回答 2

2

让我们从在一个简单条件中插入所有条件开始:

If Grade = "5" Then

End If

那么你可以使用SWITCH CASE:

 Select Case Letter_Score
       Case Letter_Score Like "[A-R]"
             ConvertScoresMOY = "F & P Remedial"
       Case val Letter_Score Like "[S-T]"
             ConvertScoresMOY = "F & P Below Proficient"
 End Select
于 2013-01-20T20:46:54.093 回答
1

您可以在另一张表中创建您的字典,然后使用 VLOOKUP() 函数在第一列中搜索值并获取第二列中的值。

于 2013-01-21T21:49:14.143 回答