在我目前的項目中,我正在製作一款紙牌遊戲。基本上它是如何工作的是我有一個名爲「lstdeck」的列表框。這是你找到所有卡片的地方。第二個被稱爲「lsthand」。這是您的手牌,當5張牌從「背板」中取出並放入您的「手牌」時創建。需要幫助顯示不同列表框中的相同列表框項目信息vb.net
當從列表框(甲板或手)中選擇一張卡時,卡信息應顯示在「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個列表框。任何幫助將不勝感激!
我首先想到的:你是如何處理的180卡? – Hockenberry 2015-02-06 07:57:24