|
-
Apr 25th, 2008, 08:05 PM
#1
Thread Starter
Registered User
[RESOLVED] [2008] Select Case multiple clauses
I don't think I can do this, but I thought I would confirm with my most trusted VB source - you!
vb.net Code:
Select Case i Case 1, 2, 3 DoSomething() End Select
Can I tell if 1, 2, or 3 got me to DoSomething()?
-
Apr 25th, 2008, 08:13 PM
#2
Re: [2008] Select Case multiple clauses
Inside the Case 1, 2, 3 you would have to check for what i is again to tell which caused it to step into that case
you'd be better off not testing for 1, 2, 3 and simply do a case for each
ie
Code:
Select Case i
Case 1
Something
Case 2
Something
Case 3
And Something
End Select
-
Apr 25th, 2008, 08:43 PM
#3
Thread Starter
Registered User
Re: [2008] Select Case multiple clauses
-
Apr 26th, 2008, 09:01 AM
#4
Re: [RESOLVED] [2008] Select Case multiple clauses
Code:
For testCTR As Integer = 0 To 10
Select Case testCTR
Case 0, 1, 2
Debug.WriteLine(testCTR.ToString.PadRight(3, " "c) & "0, 1 or 2")
Case 3
Debug.WriteLine(testCTR.ToString.PadRight(3, " "c) & "3")
Case 4 To 7
Debug.WriteLine(testCTR.ToString.PadRight(3, " "c) & "4 - 7")
Case Else
Debug.WriteLine(testCTR.ToString.PadRight(3, " "c) & "other")
End Select
Next
-
Apr 27th, 2008, 11:11 PM
#5
Re: [RESOLVED] [2008] Select Case multiple clauses
 Originally Posted by dbasnett
Code:
For testCTR As Integer = 0 To 10
Select Case testCTR
Case 0, 1, 2
Debug.WriteLine(testCTR.ToString.PadRight(3, " "c) & "0, 1 or 2")
Case 3
Debug.WriteLine(testCTR.ToString.PadRight(3, " "c) & "3")
Case 4 To 7
Debug.WriteLine(testCTR.ToString.PadRight(3, " "c) & "4 - 7")
Case Else
Debug.WriteLine(testCTR.ToString.PadRight(3, " "c) & "other")
End Select
Next
That still doesn't help him any, once he's inside the case of 1, 2 or 3, he'll still have to test i again to find out if it stepped in because i was a 1, 2 or a 3.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|