1. ## Loop/select case problem

User Aidy Rutter (AidyR@TrustMarque.com.nospam) posted:

concievable problem that can happen is happening. And I've been off for 3
weeks, and I got 3 weeks of work to catch up on.

I got a select case in a loop, but it aint working. Any ideas?

Dim x as Integer
Dim y as Integer

For x = 1 to 4

Call Somert

Select Case y
Case x = 1
Call NatureOfContract ("Public Works Contract")
Case x = 2
Call NatureOfContract ("Supply Contract")
Case x = 3
Call NatureOfContract ("Combined Contract (Mostly Public
Works)")
Case x = 4
Call NatureOfContract ("Combined Contract (Mostly
Supplies)")
End Select

Call Somert

Next x

---

2. ## Re: Loop/select case problem

User Dominic Rogers (DominicR@mercia.com.nospam) posted:

ok the problem is that you are using

Select Case y
but then each case is an x
try this:

For x = 1 to 4

Call Somert

Select Case x
Case x = 1
Call NatureOfContract ("Public Works Contract")
Case x = 2
Call NatureOfContract ("Supply Contract")
Case x = 3
Call NatureOfContract ("Combined Contract (Mostly
Public
Works)")
Case x = 4
Call NatureOfContract ("Combined Contract (Mostly
Supplies)")
End Select

Call Somert

Next x

3. ## Re: Loop/select case problem

User Shevchenko, Dmitry (DShevchenko@flagship.ru.nospam) posted:

Dim x as Integer
Dim y as Integer

For x = 1 to 4

Call Somert

Select Case x
Case 1
Call NatureOfContract ("Public Works Contract")
Case 2
Call NatureOfContract ("Supply Contract")
Case 3
Call NatureOfContract ("Combined Contract (Mostly Public
Works)")
Case 4
Call NatureOfContract ("Combined Contract (Mostly
Supplies)")
End Select

Call Somert

Next x

Aidy,

why should you use y?

4. ## Re: Loop/select case problem

User Aidy Rutter (AidyR@TrustMarque.com.nospam) posted:

Thanks Dom, Dmitry. I've changed variable to 'x' and it's completely
skipping the case statements; but I'm getting this in the variable window.

x%: 1
Result%: 0

Can you tell me why?

Aidy

5. ## Re: Loop/select case problem

User Dominic Rogers (DominicR@mercia.com.nospam) posted:

try this:

For x = 1 to 4

Call Somert

y = x
Select Case y
Case y = 1
Call NatureOfContract ("Public Works Contract")
Case y = 2
Call NatureOfContract ("Supply Contract")
Case y = 3
Call NatureOfContract ("Combined Contract (Mostly
Public
Works)")
Case y = 4
Call NatureOfContract ("Combined Contract (Mostly
Supplies)")
End Select

Call Somert

Next x

6. ## Re: Loop/select case problem

User Aidy Rutter (AidyR@TrustMarque.com.nospam) posted:

Cheers Dom. It's still skipping through though. I might just go home.

Aidy

7. ## Re: Loop/select case problem

User Shevchenko, Dmitry (DShevchenko@flagship.ru.nospam) posted:

That's something mysterious with your code.
I have tried the loop/select case and it has worked for me.
Maybe you have some kind of misspelling?

8. ## Re: Loop/select case problem

User Dominic Rogers (DominicR@mercia.com.nospam) posted:

try this as your code is wrong, you dont need y = after each case:

For x = 1 to 4

Call Somert

y = x
Select Case y
Case 1
Call NatureOfContract ("Public Works Contract")
Case 2
Call NatureOfContract ("Supply Contract")
Case 3
Call NatureOfContract ("Combined Contract (Mostly
Public
Works)")
Case 4
Call NatureOfContract ("Combined Contract (Mostly
Supplies)")
End Select

Call Somert

Next x

9. ## Re: Loop/select case problem

User Shevchenko, Dmitry (DShevchenko@flagship.ru.nospam) posted:

Aidy,

make sure that you don't change x between
For x=1 to 4 and

Select Case

Are you sure that Call Somert doesn't change x?

10. ## Re: Loop/select case problem

User Aidy Rutter (AidyR@TrustMarque.com.nospam) posted:

Dom thanks, this works. I can continue my testing now.

Cheers all

Aidy

Page 1 of 2 12 Last

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.