我不確定要在代碼中更改哪些內容以使列表框顯示每輛車。我想讓我的車輛結構在列表框中顯示
Public Class Form1
Structure Vehicle
Dim Make As String
Dim Model As String
Dim Doors As Integer
Dim Hp As Integer
Dim VIN As String
End Structure
Private Sub btnGo_Click(sender As Object, e As EventArgs) Handles btnGo.Click
Dim Vehicles(9) As Vehicle
Vehicles(0).Make = "Chevrolet"
Vehicles(1).Make = "Dodge"
Vehicles(2).Make = "Nissan"
Vehicles(3).Make = "Mitsubishi"
做了一個for循環來顯示每個做
For i = 0 To 4 Step 1
ls.Items.Add(Vehicles(i).Make.ToString)
Next
End Sub
首先,你不需要在'String'上調用'ToString'。除此之外,這不起作用? – David
沒有.tostring我得到「值不能爲空。」 – user3268184
與tostring我得到「對象引用未設置爲對象的實例。」 – user3268184