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

  • SEARCH
  • Home
  • 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 8746229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:09:44+00:00 2026-06-13T12:09:44+00:00

The code below works, I can’t help thinking there is a better way to

  • 0

The code below works, I can’t help thinking there is a better way to do this though. Is anyone experienced with using functions in conjunction with Select Statements.
The code I would expect to work would be something along the lines…

Select Case File.EndsWith()
Case "example 1", Case "example2"

This code works:

Select Case File.EndsWith(File)
    Case tFile.EndsWith("FileA.doc")
        sbExisting.AppendLine(Report.sbStart.ToString)
        sbExisting.AppendLine(Report.sbHeaders.ToString)
        sbExisting.AppendLine(Report.sbItems.ToString)
        sbExisting.AppendLine(Report.sbSubreport.ToString)
        sbExisting.AppendLine(Report.sbEnd.ToString)
        sbExisting.AppendLine(Report.sbCol.ToString)
    Case tFile.EndsWith("FileB.doc")
        'Slave
        sbExisting.AppendLine(Report.sbStart.ToString)
        sbExisting.AppendLine(Report.sbItems.ToString)
        sbExisting.AppendLine(Report.sbHeaders.ToString)
        sbExisting.AppendLine(Report.sbCol.ToString)
        sbExisting.AppendLine(Report.sbEnd.ToString)
End Select
  • 1 1 Answer
  • 0 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-06-13T12:09:45+00:00Added an answer on June 13, 2026 at 12:09 pm

    .EndsWith() returns true or false. That’s all you have.

    If you do want to use Select with that, then the idiomatic way is

    Select Case True
        Case tFile.EndsWith("MSMaster.tmp")
            ...
        Case tFile.EndsWith("MSSlave.tmp")
            ...
    End Select
    

    Having multiple choices on the same line would be of not much difference:

    Select Case True
        Case tFile.EndsWith("example 1"), tFile.EndsWith("example 2")
            ...
        Case tFile.EndsWith("example 3"), tFile.EndsWith("example 4")
            ...
    End Select
    

    If you already have a list of choices in an array/list/collection, you can also use

    Dim choices1 = New String() {"example 1", "example 2"}
    Dim choices2 = New String() {"example 3", "example 4"}
    
    Select Case True
        Case choices1.Any(Function(s) tFile.EndsWith(s))
            ...
        Case choices2.Any(Function(s) tFile.EndsWith(s))
            ...
    End Select
    

    Or do the same inline if you prefer:

    Select Case True
        Case (New String() {"example 1", "example 2"}).Any(Function(s) tFile.EndsWith(s))
            ...
        Case (New String() {"example 3", "example 4"}).Any(Function(s) tFile.EndsWith(s))
            ...
    End Select
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please can anyone help me out with this problem? This code below works perfectly
I have the code below, which works fine it can be viewed for an
I can't understand how works the code below: class Host: name = None fileList
I can't get this code to work. Declared playpauseButton just above the given below
The code below works fine but, in the textbox the decimal value has this
Everything in the code below works except for the binding on the ContextMenu. This
Can anyone help me write this query more efficiently? I have a table that
The code below works insomuch that I can successfully download the directory recursively. But,
The code below works, but I know it can't be the most efficient. Is
My problem is: the code below works fine but there is one special case.

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.