需要帮助显示来自不同列表框vb.net的相同列表框项目信息吗

需要帮助显示来自不同列表框vb.net的相同列表框项目信息吗,.net,vb.net,listbox,.net,Vb.net,Listbox,在我目前的项目中,我正在做一个纸牌游戏。基本上,它的工作原理是我有一个名为lstdeck的列表框。这是你找到所有卡片的地方。第二种被称为lsthand。这是你的手牌,当5张牌从牌堆中取出并放入你的手牌时创建 从列表框组或手牌中选择卡片时,卡片信息应显示在txtdescription中。但是,我不知道如何让多个listbox.selecteditem调用同一个布尔值。下面是我希望能奏效但失败的一小部分 Dim CurrentList as string Private Sub lsthand_Se

在我目前的项目中,我正在做一个纸牌游戏。基本上,它的工作原理是我有一个名为lstdeck的列表框。这是你找到所有卡片的地方。第二种被称为lsthand。这是你的手牌,当5张牌从牌堆中取出并放入你的手牌时创建

从列表框组或手牌中选择卡片时,卡片信息应显示在txtdescription中。但是,我不知道如何让多个listbox.selecteditem调用同一个布尔值。下面是我希望能奏效但失败的一小部分

Dim CurrentList as string
Private Sub lsthand_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles lsthand.SelectedIndexChanged
    Currentlist = "lsthand"
    CheckCards()
End Sub

Private Sub CheckCards()
    Dim FindSelection As String = ".selecteditem"
    If Currentlist & FindSelection = "Face Card 1" Then
       txtdescription.text = "This is the first face card."
在上面的实例中,选择了列表框中显示的名为Face card 1的卡。它位于哪个列表框中并不重要。希望添加两个字符串,一个是lsthand,一个是.selecteditem,结果是:lsthand.selecteditem。不幸的是,这没有起作用。有人知道这个问题的解决办法吗


此外,我意识到我可以制作一个lstdeck.selecteditem Private sub来选中该列表框,另一个用于lsthand。但我使用了大约180种不同的卡片和6个列表框。任何帮助都将不胜感激

只需制作一个sub来处理所有已更改的SelectedIndex

我想你想要这样的东西:

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    ListBox1.Items.AddRange(New String() {"dog", "cat", "rabbit", "tux"})
    ListBox2.Items.AddRange(New String() {"earth", "fire", "water", "air"})
    ListBox3.Items.AddRange(New String() {"Green Day", "Limp Bizkit", "Donots", "Guano Apes"})
End Sub

Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged, ListBox2.SelectedIndexChanged, ListBox3.SelectedIndexChanged
    If DirectCast(sender, ListBox).SelectedItem = "cat" Then
        MsgBox("best animal!")
    Else
        MsgBox("something else...")
    End If
End Sub

我的第一个想法是:你如何处理这180张卡?