Use the switch activity to find the grade of a student based on the score in a subject

I was working on the task, while I am trying to use switch actvity I am unable to give condition to the switch expression.

Here are the grades of the “score” - variable

A: >90
B: 80-89
C: 70-79
D: 70-69

Please,help me on this


How about the following expression?

arrBorder = {90,80,70,60}


Chr(65+arrBorder.Where(Function(i) i>score).Count)


Sample (2.9 KB)


Switch doesn’t work like that. Switch takes a single value. For what you’re trying to do, you will want to use Else If.

Hi @Sai_Kiran_Diyya

Try this way. This should work for you.

score = The value you give from Input Dialog acitivty ' Assuming score is an integer variable

If score > 90 Then
    ' Code for grade A
ElseIf score >= 80 AndAlso score <= 89 Then
    ' Code for grade B
ElseIf score >= 70 AndAlso score <= 79 Then
    ' Code for grade C
ElseIf score >= 60 AndAlso score <= 69 Then
    ' Code for grade D
    ' Code for other cases or default
End If

the below image will give you better understanding: