所以我试图使用一个列表框来访问我的二维数组中的变量。我不确定最好的方法是什么。现在我正在使用列表框的 selectedindex 来访问它,但我只看到第二个维度显示在我的消息框中。任何帮助,将不胜感激。
Option Explicit On
Option Strict On
Option Infer Off
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
lstInventory.Items.Add("Hand Grenade")
lstInventory.Items.Add("9mm Ammo Box")
lstInventory.Items.Add(".40 Ammo Box")
lstInventory.SelectedIndex = 0
End Sub
Dim dblInventoryItem(,) As Double = {{10.99, 5},
{5.99, 10},
{8.99, 8}}
Private Sub btnCheck_Click(sender As System.Object, e As System.EventArgs) Handles btnCheck.Click
Dim intRow As Integer = lstInventory.SelectedIndex
MessageBox.Show(dblInventoryItem(intRow, 1).ToString)
End Sub
End Class