Select Case and If Then Decisions

  • Thread starter Thread starter DAL
  • Start date Start date
D

DAL

I have a list of items in a list box and have used the Select Case decision
structure to add names to a label when a selection is made. How do I use an
If Then decision structure to concatenate two selections in different
listboxes.

ie.

If listbox1.selectedindex = case 0 And listbox2.selectedindex = case 25
Then
label1.text = case0 + case 25
End If
 
Well you could better show us your hole decission structure

also note that in most situations when a lot of possible cases are involved
it might be faster and better ( readability ) to use a Select case
structure


regards

Michel Posseth
 
label1.text = listbox1.selecteditem.tostring + listbox2.selecteditem.tostring

or am i missing something?
 
DAL said:
I have a list of items in a list box and have used the Select Case
decision structure to add names to a label when a selection is made. How
do I use an If Then decision structure to concatenate two selections in
different listboxes.

Personally, I'd use /another/ Select Case, as in

Option Strict On

Dim sKey as String _
= listbox1.SelectedIndex.ToString() _
& ":" & listbox2.SelectedIndex.ToString()

Select Case sKey
Case "0:25"
label1.Text = "0 25" ' ?
label1.Text = listbox1.SelectedItem.Text _
& " " & listbox2.SelectedItem.Text ' perhaps better?
End Select

HTH,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top