2010-11-18 20 views
2

我需要在VB .NET中的ListBox組件上顯示一個列表。如何獲得一個列表大小的VB VB?

// params is a string representing a path, empty means root folder 
params.itemsPath = "" 

// resp is a response object, here it is a String[] 
resp = myAPI.browseTags(params) 

Dim listSize As Integer 
listSize = resp.itemsList.GetLength 

Dim i As Integer 
For i = 0 To listSize 
    ListBox1.Items.Add(resp.itemsList(i).itemName) 
Next 

我不熟悉VB.NET,這應該是一個非常簡單的問題,但我需要幫助!

代碼「resp.itemsList.GetLength」藍色標有下劃線且有讀取工具提示:

「爲參數的「公共職能對GetLength‘尺寸’(尺寸爲整數)作爲整數參數未指定」 。

我在這裏做錯了什麼? 在此先感謝!

回答

0

嘗試GetLength(0)

MSDN documentation

備註

GetLength進行的一個例子是 GetLength進行(0),它返回的 第一維的元素數 陣列。

+0

的感謝!這個伎倆! – gtludwig 2010-11-18 13:53:10

3

有,調用函數COUNT():

List.Count