Solved

StartsWith Select Case

Posted on 2006-10-27
3
1,014 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
ID: 17821466
No, Case allows only constants. Do this with If - ElseIf - Else operator.
0
 
LVL 1

Assisted Solution

by:super786
super786 earned 200 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb.net 2 43
Getting multiple values from a dataset ASP.NET(VB) 3 49
Vb. Net application freezes 9 46
Close form "before" open 3 40
This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

770 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