最标准的代码:
Private Sub Text1_GotFocus(Index As Integer)
Dim i, Max As Integer
Dim Sum As Long
Max = Text1.UBound
Sum = 1
For i = 0 To Max
If i <> Max Then
Sum = Sum * Val(IIf(IsNumeric(Text1(i).Text), Text1(i).Text, 1))
Else
Text1(i).Text = Sum
End If
Next i
End Sub
调个得到焦点的函数
TEXT2.getpoint()
text2=val(text1)*val(text2)
第一种方法:
Private Sub Text1_Click(Index As Integer)
If Index = 2 Then
Text1(2).Text = Val(Text1(0).Text) * Val(Text1(1).Text)
End If
End Sub
第二种方法:
Private Sub Text1_GotFocus(Index As Integer)
If Index = 2 Then
Text1(2).Text = Val(Text1(0).Text) * Val(Text1(1).Text)
End If
End Sub