|
-
Jul 15th, 2010, 10:05 AM
#1
Thread Starter
Fanatic Member
Perform all cases in case statement
Hi all,
Is there a way to make a VB case statement evaluate all the cases? Similar to a java switch statement (without the break).
Thanks,
Strick
-
Jul 15th, 2010, 10:37 AM
#2
Re: Perform all cases in case statement
I would say there is not way in vb.net to do this using a select case statement. here's what we find on MSDN :
"If testexpression matches any Caseexpressionlist clause, the statements following that Case statement are executed up to the next Case statement or the End Select statement. Control then passes to the statement following End Select. If testexpression matches an expressionlist clause in more than one Case clause, only the statements following the first match are executed."
I' guess you would need to use multiple "if" statement to do what you need.
Alex
.NET developer
"No. Not even in the face of Armageddon. Never compromise." (Walter Kovacs/Rorschach)
Things to consider before posting.
Don't forget to rate the posts if they helped and mark thread as resolved when they are.
.Net Regex Syntax (Scripting) | .Net Regex Language Element | .Net Regex Class | DateTime format | Framework 4.0: what's new
My fresh new blog : writingthecode, even if I don't post much.
System: Intel i7 920, Kingston SSDNow V100 64gig, HDD WD Caviar Black 1TB, External WD "My Book" 500GB, XFX Radeon 4890 XT 1GB, 12 GBs Tri-Channel RAM, 1x27" and 1x23" LCDs, Windows 10 x64, ]VS2015, Framework 3.5 and 4.0 
-
Jul 15th, 2010, 04:23 PM
#3
Thread Starter
Fanatic Member
Re: Perform all cases in case statement
Hi,
Thanks for your reply. Figured as much just thought I'd ask. If statements it is then...
-
Jul 15th, 2010, 08:19 PM
#4
Re: Perform all cases in case statement
If <Case1> Then
End If
If <Case2> Then
End If
'Repeat
-
Jul 15th, 2010, 08:43 PM
#5
Fanatic Member
Re: Perform all cases in case statement
if there is no break; statement in a case statement then all the case statement might evaluate by default
-
Jul 15th, 2010, 08:54 PM
#6
Re: Perform all cases in case statement
how about using "Finally" after all your cases? put all the code you want to execute in the Finally block.
i'm curious though, if you're trying to execute ALL the cases, why even have the Select/Case structure? wouldn't you just... 'do' it all minus all the Select/Case code?
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
|