Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

StartsWith Select Case

Posted on 2006-10-27
3
Medium Priority
?
1,034 Views
Last Modified: 2008-01-09
Is there a slick way to use the StartsWith in combination with a Select/Case? Something like this (which doesn't compile):

        Select Case TextBox1.Text.ToUpper
            Case String.StartsWith("AB")
            ' ...
        End Select

Instead of a bunch of:

 If TextBox1.Text.ToUpper.StartsWith("AB") Then
 ElseIf ..  ("CD")

and so on.
0
Comment
Question by:GivenRandy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 1200 total points
ID: 17821466
No, Case allows only constants. Do this with If - ElseIf - Else operator.
0
 
LVL 1

Assisted Solution

by:super786
super786 earned 800 total points
ID: 17821492
If you can define the length of your search string (ie, 2 characters) then you can do:

Select Case TextBox1.Text.SubString(0, 2).ToUpper()
   Case "AB"
   Case "CD"
   Case "EF"
end select

but if you have a variable length search string, then you can't do it unless you can specify a delimiter or something.  Ie, all strings start with the code string followed by a colon (:).  Then you can pull the string up to the colon before you run it through the select case.
0
 
LVL 9

Author Comment

by:GivenRandy
ID: 17821597
That's the way I had done it. Didn't know if they was some Framework trick I was missing (the thing is massive).
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question