单选题
下列程序的执行结果是( )。 Private Sub Form_Activate() Dim score(3)As Integer,total As Integer Dim aa score AS Variant score(1)=50:score(2)=14:score(3)=36 total=0:i=0 For Each aa score In score i=i+1 tota1=tota1+aa_score Print i,aa_score,tota1 Next End Sub
【正确答案】
A
【答案解析】[解析] 本题考查For Each In语句。该语句的使用形式为:For Each成员 In 数组 …Next,适用于不关心数组中的元素个数或者不清楚有多少个元索,使用时要求成员为变体类型变量。当激活窗体时,对score数组中的每个元素进行求和,同时i记下当前计算数组元素的个数。默认数组下标从0开始,题中score数组中含有4个元素,输出4行。