Count elements in a variant field

Hi,

I need your help: I don’t know how to get the number of elements of the “progetti” field in the following script:

Sub Click(Source As Button)

Dim db As NotesDatabase

Dim s As New NotesSession

Dim profile As notesdocument

Dim progetti  As Variant



Set db = s.GetDatabase ("server","db.nsf")

Set profile = db.GetProfileDocument ("frm008")

Set progetti = profile.GetFirstItem ("prof_projects")

—> what should I do to get now the number of items of the “progetti” field?

Thank you

Bye

Andrea

Subject: Count elements in a variant field

As has been already suggested the UBound function will give you the Upper Boundry of the Variable. However the Base by default is Zero so it will return 9 if there are 10 elements because the first element returns 0. You can change the Base to to 1 so that UBound returns 10 for a 10 element array by setting

Option Base 1

in the Options tab.

Subject: Hmmm

I had forgotten that. I wouldn’t adjust the base, though. I would add one to the integer value of the result to stay in the habit of having Base 0.

Subject: RE: Hmmm

I agree I always (well almost always) leave the Base at 0, I find it easier to remember to add One than trying to remeber if the Base was changed. I part because I am called on to work with lots of peoples different code.

Subject: Solved

Thank you all for the good indications.With your good advises I have solved my problem.

Thank you again

Bye

Andrea

Subject: UBound ( progetti )

Returns the upper bound for one dimension of an array.

Syntax

UBound ( arrayName [ , dimension ] )

Elements

arrayName

The name of an array.

dimension

Optional. An integer argument that specifies the array dimension for which you want to retrieve the upper bound.

Return value

UBound returns an Integer.

Usage

The default value for dimension is 1.

LotusScript sets the upper bound for each array dimension when you declare a fixed array, or when you use ReDim to define the array dimensions of a dynamic array.

Subject: Count elements in a variant field

There is always evaluate in LSdim tmp as Variant

tmp = Evaluate({@Elements( prof_projects)},profile)

Msgbox tmp(0)