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