Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 193379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:30:20+00:00 2026-05-11T16:30:20+00:00

I am writing some code in VB.NET that uses a switch statement but in

  • 0

I am writing some code in VB.NET that uses a switch statement but in one of the cases it needs to jump to another block. In C# it would look like this:

switch (parameter)
{
    case "userID":
        // does something here.
    case "packageID":
        // does something here.
    case "mvrType":
        if (otherFactor)
        {
            // does something here.
        }
        else
        {
            goto default;
        }
    default:
        // does some processing...
        break;
}

However, I don’t know how to convert this to VB.NET. I tried this:

Select Case parameter 
    Case "userID"
        ' does something here.
    Case "packageID"
        ' does something here.
    Case "mvrType" 
        If otherFactor Then 
            ' does something here. 
        Else 
            GoTo Case Else 
        End If 
    Case Else 
        ' does some processing... 
        Exit Select 
End Select     

But when I do this I get a compiler error: “Identifier expected”. There’sa squiggly line under “Case”. Any ideas?

Also, is it wrong to use a GoTo statement in this case? It seems any other way I would have to re-write it.


I have changed my code to as follows:

If otherFactor AndAlso parameter = "mvrType" Then 
    'does something here 
Else 
    ' My original "Select Case statement" here without the case for "mvrType" 
End If
  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:30:20+00:00Added an answer on May 11, 2026 at 4:30 pm

    There is no equivalent in VB.NET that I could find. For this piece of code you are probably going to want to open it in Reflector and change the output type to VB to get the exact copy of the code that you need. For instance when I put the following in to Reflector:

    switch (args[0])
    {
        case "UserID":
            Console.Write("UserID");
            break;
        case "PackageID":
            Console.Write("PackageID");
            break;
        case "MVRType":
            if (args[1] == "None")
                Console.Write("None");
            else
                goto default;
            break;
        default:
            Console.Write("Default");
            break;
    }
    

    it gave me the following VB.NET output.

    Dim CS$4$0000 As String = args(0)
    If (Not CS$4$0000 Is Nothing) Then
        If (CS$4$0000 = "UserID") Then
            Console.Write("UserID")
            Return
        End If
        If (CS$4$0000 = "PackageID") Then
            Console.Write("PackageID")
            Return
        End If
        If ((CS$4$0000 = "MVRType") AndAlso (args(1) = "None")) Then
            Console.Write("None")
            Return
        End If
    End If
    Console.Write("Default")
    

    As you can see you can accomplish the same switch case statement with If statements. Usually I don’t recommend this because it makes it harder to understand, but VB.NET doesn’t seem to support the same functionality, and using Reflector might be the best way to get the code you need to get it working with out a lot of pain.

    Update:

    Just confirmed you cannot do the exact same thing in VB.NET, but it does support some other useful things. Looks like the IF statement conversion is your best bet, or maybe some refactoring. Here is the definition for Select…Case

    http://msdn.microsoft.com/en-us/library/cy37t14y.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 205k
  • Answers 205k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer After some more searching, I've found a very nice article… May 12, 2026 at 8:59 pm
  • Editorial Team
    Editorial Team added an answer Have you implemented the delegate and datasource methods? May 12, 2026 at 8:59 pm
  • Editorial Team
    Editorial Team added an answer Interesting. It appears that firebug is lying to me. Using… May 12, 2026 at 8:59 pm

Related Questions

i am writing some code in vb.net that will be generating a pdf file.
I am writing a library in VB.NET in which I have added, among others,
I am using VB.NET and I am trying to come up with some algorithm
Maybe you can help me... I am writing a program in Windows Mobile that

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.