# 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
Visual Basic.NET.NET Programming

Last Comment
RIAS

8/22/2022 - Mon
Nitin Sontakke

Why not just NumberOFPictures / 47? Take the answer, make it an Integer and just add 1. Will that not work?
Nitin Sontakke

When is the slide number = 1?
RIAS

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

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
RIAS

Thanks, will try and be right back
AndyAinscow

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....
RIAS

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
AndyAinscow

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.