come ottenere una dimensione lista em VB .NET?
-
26-09-2019 - |
Domanda
Ho bisogno di visualizzare un elenco su un componente ListBox 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
Non ho familiarità con VB .NET e questo dovrebbe essere un problema molto semplice, ma ho bisogno di aiuto!
Il codice 'resp.itemsList.GetLength' è sottolineato in blu e c'è un tooltip che dice:
"L'argomento non specificato per il parametro 'dimensione' della 'Funzione Pubblica GetLength (dimensione As Integer) As Integer".
Che cosa sto facendo male qui? Grazie in anticipo!
Soluzione
Prova GetLength(0)
Note
Un esempio di GetLength è GetLength (0), che restituisce il numero di elementi nella prima dimensione di Array.
Altri suggerimenti
c'è, chiamata di funzione Count ():
List.Count
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow