# Better way of writing this piece of code in vb.net

Hello,
i have code :

``````    If NumberOFPictures <= 47 Then
Slidenumber = 2
ElseIf NumberOFPictures > 47 And NumberOFPictures <= 94 Then
Slidenumber = 3
ElseIf NumberOFPictures > 94 And NumberOFPictures <= 141 Then
Slidenumber = 4
ElseIf NumberOFPictures > 141 And NumberOFPictures <= 188 Then
Slidenumber = 5
ElseIf NumberOFPictures > 188 And NumberOFPictures <= 235 Then
Slidenumber = 6

End If``````
Is there any better way of writing this as the NumberOFPictures can be  even 2000

Cheers
Nitin Sontakke

Why not just NumberOFPictures / 47? Take the answer, make it an Integer and just add 1. Will that not work?
When is the slide number = 1?

Thanks, The slide 1 is the title one so it starts with 2 .
SOLUTION
Rgonzo1971

membership
Create an account to see this answer
Signing up is free. No credit card required.

Thanks, will try and be right back
You can use the \ operator to perform integer division (take care with the / operator, they are not the same).
so 46\47 is zero, 47\47 is one, 94\47 is two....

Any suggestion then Andy
Rgonzo1971

I supposed you are counting from 0 but 48 units per page like in your previous example
I'm already  using the integer division '\' in my suggestion
You want something like
slideno = 2 + (picno \ 47)
but I suspect your original code isn't correct.  You have more pictures on the first page than on subsequent pages.