Home All Groups Group Topic Archive Search About

Select Case and If Then Decisions

Author
2 Feb 2006 7:31 AM
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

Author
2 Feb 2006 7:42 AM
m.posseth
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


Show quoteHide quote
"DAL" <dalmailbox-m***@yahoo.com> wrote in message
news:utMSzq8JGHA.1288@TK2MSFTNGP09.phx.gbl...
>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
>
Author
2 Feb 2006 9:13 AM
guy
label1.text = listbox1.selecteditem.tostring + listbox2.selecteditem.tostring

or am i missing something?



Show quoteHide quote
"DAL" wrote:

> 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
>
>
>
Author
2 Feb 2006 12:04 PM
Phill W.
"DAL" <dalmailbox-m***@yahoo.com> wrote in message
news:utMSzq8JGHA.1288@TK2MSFTNGP09.phx.gbl...
> 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.