Advertisement

10.03.2007 at 01:04PM PDT, ID: 22870389
[x]
Attachment Details

'Select Case' in vb.net

Asked by tiehaze in Microsoft Visual Basic.Net, Microsoft Visual Studio Express, Visual Studio

Tags: ,

I have the following script which is using 'Select Case':

        Dim ctl As ToolStripButton = CType(sender, ToolStripButton)
        Dim MoveUp As Boolean = False
        Dim thisLV As ListView = AccountsLV

        Select Case ctl.Name
            Case "UpBtn1"
                MoveUp = True
                thisLV = ListView1
            Case "DownBtn1"
                MoveUp = False
                thisLV = ListView1
            Case "UpBtn2"
                MoveUp = True
                thisLV = ListView2
            Case "DownBtn2"
                MoveUp = False
                thisLV = ListView2
            Case "UpBtn3"
                MoveUp = True
                thisLV = ListView3
            Case "DownBtn3"
                MoveUp = False
                thisLV = ListView3
        End Select

As you can see, if the Name of the ToolStripButton begins with "Up", then I want 'MoveUp = True'. If not, then I want 'MoveUp = False'. Then, I want the number at the end of the toolstripbutton name to correspond with the ListView (i.e. DownBtn1 => 'thisLV = ListView1' or UpBtn3 => 'thisLV = ListView3')

Is there anyway to condense this? I am planning on having over 20 cases like this and don't want the code to get to lengthy.Start Free Trial
[+][-]10.03.2007 at 01:29PM PDT, ID: 20009788

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual Basic.Net, Microsoft Visual Studio Express, Visual Studio
Tags: case, select
Sign Up Now!
Solution Provided By: Idle_Mind
Participating Experts: 2
Solution Grade: A
 
 
[+][-]10.03.2007 at 01:32PM PDT, ID: 20009821

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.03.2007 at 01:34PM PDT, ID: 20009840

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.03.2007 at 01:50PM PDT, ID: 20009937

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_1_20070628