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

Open in new window

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

Cheers
RIASAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nitin SontakkeDeveloperCommented:
Why not just NumberOFPictures / 47? Take the answer, make it an Integer and just add 1. Will that not work?
0
Nitin SontakkeDeveloperCommented:
When is the slide number = 1?
0
RIASAuthor Commented:
Thanks, The slide 1 is the title one so it starts with 2 .
0
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

Rgonzo1971Commented:
HI,

pls try
Slidenumber =2+(NumberOFPictures \ 48) 

Open in new window

0
RIASAuthor Commented:
Thanks, will try and be right back
0
AndyAinscowFreelance programmer / ConsultantCommented:
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....
1
RIASAuthor Commented:
Any suggestion then Andy
0
Rgonzo1971Commented:
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
1
AndyAinscowFreelance programmer / ConsultantCommented:
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.
0
AndyAinscowFreelance programmer / ConsultantCommented:
A more brute force approach would be something like this:
        slideno = 2
        While picno > 47
            slideno = slideno + 1
            picno = picno - 47
        End While

If you wanted something other than 47 pictures per page then just adjust accordingly
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RIASAuthor Commented:
Thanks Andy! Will try and brb
0
RIASAuthor Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.