Mario De Ghetto

Microsoft MVP – Visual Basic (VB.NET: Programmare che passione!)

#24: Limite superiore e inferiore di un array

Pubblicato da Mario De Ghetto su 26 Febbraio 2008

Per trovare i limiti superiore e inferiore di un array monodimensionale (vettore), in VB6 avevamo le funzioni UBound() e LBound().

Con VB.NET dobbiamo invece utilizzare due metodi messi a disposizione dall’array, cioè GetUpperBound e GetLowerBound, come nel seguente esempio:

Dim a() As Integer = {1, 2, 3}
Dim limiteSuperiore As Integer = a.GetUpperBound(0)
Dim limiteInferiore As Integer = a.GetLowerBound(0)

Lascia un commento

XHTML: Puoi usare questi tag: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>