Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get a list size em VB .NET?

I need to display a list on a ListBox component in VB .NET.

// 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

I'm not familiar with VB .NET and this should be a very simple issue, but I need help!

The code 'resp.itemsList.GetLength' is underlined in blue and there's a tooltip that reads:

"Argument not specified for parameter 'dimension' of 'Public Function GetLength(dimension As Integer) As Integer".

What am I doing wrong here? Thanks in advance!

like image 586
gtludwig Avatar asked Dec 29 '22 05:12

gtludwig


2 Answers

there is, call function Count():

List.Count    
like image 140
user2688807 Avatar answered Jan 08 '23 01:01

user2688807


Try GetLength(0)

From MSDN documentation:

Remarks

An example of GetLength is GetLength(0), which returns the number of elements in the first dimension of the Array.

like image 28
Matt Avatar answered Jan 08 '23 01:01

Matt