Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a Select Case with Null

Status
Not open for further replies.

Davidwazza

Programmer
Oct 31, 2003
16
AU
Hey All

I have been having some trouble with this grading program again.
Here it is thus far:

'Functions corresponding to each grade

Private Sub UpdateARIGrade()

Select Case ([intARI] \ 1) '<-- integer division
Case Is >= 90
Me![ARIgrade] = &quot;D&quot;
Case 80 To 89
Me![ARIgrade] = &quot;C&quot;
Case 55 To 79
Me![ARIgrade] = &quot;P&quot;
Case Else
Me![ARIgrade] = &quot;F&quot;
End Select

End Sub

... I need to ensure that if the cell &quot;ARIgrade&quot; is null, it won't display anything. I thought of putting
Case Null
Me![ARIgrade] = &quot; &quot;
just before case else, but this doesnt seem to be workin.

Thanx in advance, David.
 
Code:
If not isnull (Me![ARIgrade]) then
    Select Case ([intARI] \ 1)    '<-- integer division
    ...

as a suggestion

Redapples

Want the best answers? See FAQ181-2886

 
Hi Davidwazza,

I'm fascinated by the integer division of an integer by 1 - unless intARI isn't an integer (which highlights why I dislike the naming convention). As for an answer to your question, I think RedApples has it.

Enjoy,
Tony
 
Hi, thanks for that redapples, dont know why I didnt think of that!

In response to the integer division, that was a result of another question I posted, concerning roundings of percentages. For example, if the percentage was 89.9% (as would be displayed in intARI), but Select Case only evaluates integers, say >= 90. Thus, &quot;apparently&quot; it makes it possible to round up using \ 1.
Dont know if I helped, or just confused you even more!

David.
 
Hi David,

My point was that an Integer variable wouldn't change when divided by 1. If it has a value of 89.9 then intARI isn't an Integer and shouldn't be called intARI.

But what do you mean by Select Case only evaluates integers?

Enjoy,
Tony
 
Hey.

Firstly, yes I admit the name is a bit misleading - the value intARI is not really an integer, but more of a float variable. Just my definition of an integer is a number at the moment!

Hence, it is possible to have intARI = 89.9, as you said. With Select case, you cannot have
Case 80 <= [intARI] <= 90, but rather 80 To 90.
As you can see, this causes a problem, as the next one down would be Case 60 To 79. Hence, where would the number 79.5 go?

The answer lies with that divisible by 1 equation. To the simple observer, it doesnt do anything. But, (I think) what really happens is 1 is an integer, so it promotes the float variable to an integer variable, and does the equation divided by 1. Obviously, this doesnt actually do anything, but it does the promotion to what we want. It also rounds appropiately, which is very convenient.

As I said, someone else helped me with this, and I am only using my knowledge from C Programming to explain what would happen in that.

Ta, David.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top