Select case statement advise

J

John

Hi

I have the following criteria to calculate grade form marks;

Fail = less than 50%
Pass = 50% - 59%
Pass = 60% - 69%
Merit = 70% - 79%
Merit = 80% - 89%
Distinction = 90% - 100%

How can I turn it into vb.net Select case statement?

Thanks

Regards
 
Z

zacks

Hi

I have the following criteria to calculate grade form marks;

Fail = less than 50%
Pass = 50% - 59%
Pass = 60% - 69%
Merit = 70% - 79%
Merit = 80% - 89%
Distinction = 90% - 100%

How can I turn it into vb.net Select case statement?

Assuming that 100% is the maximum value for grade then:

select case grade
case is >= 90
'process distinction
case is >= 80
' process merit
case is >= 70
' process other merit
case is >= 60
' process pass
case is >= 50
' process other pass
case else
' process fail
end slect
 
B

BobRoyAce

One angle of attack would be to take the numeric grade, divide it by
10, and take the INT of that. For example:

Dim i As Integer = Int(NumericGrade / 10)

Then, your select...case would look for PASS s 5 or 6, MERIT as 7 or
8, etc.

Select Case i
Case 5,6 : ' PASS
Case 7,8: ' MERIT
'etc.
End Select

If NumericGrade can be > 100, would have to code
accordingly...perhaps, using Case Else.
 
J

John

Thanks. I am getting an "Option Strict On prohibits operands of type Object
for operator '>='" error on each of 90,80,70,60,50. Any ideas?

Thanks again

Regards

Hi

I have the following criteria to calculate grade form marks;

Fail = less than 50%
Pass = 50% - 59%
Pass = 60% - 69%
Merit = 70% - 79%
Merit = 80% - 89%
Distinction = 90% - 100%

How can I turn it into vb.net Select case statement?

Assuming that 100% is the maximum value for grade then:

select case grade
case is >= 90
'process distinction
case is >= 80
' process merit
case is >= 70
' process other merit
case is >= 60
' process pass
case is >= 50
' process other pass
case else
' process fail
end slect
 
H

Harry

John said:
Thanks. I am getting an "Option Strict On prohibits operands of type
Object for operator '>='" error on each of 90,80,70,60,50. Any ideas?

Thanks again

I would appear that your values are objects. Convert them to integer
 
A

Armin Zingler

John said:
Thanks. I am getting an "Option Strict On prohibits operands of type
Object for operator '>='" error on each of 90,80,70,60,50. Any
ideas?

The type of the variable containing the percentage values is Object? Why?


Armin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top