Solved

StartsWith Select Case

Posted on 2006-10-27
3
1,007 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
3 Comments
 
LVL 48

Accepted Solution

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

Assisted Solution

by:super786
super786 earned 200 total points
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

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…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now