Private Sub Command1_Click() Dim a a = Split(Text1.Text) Dim s As Single For i = LBound(a) To UBound(a) s = s + a(i) Next i MsgBox s / (UBound(a) + 1) End Sub Private Sub Form_Load() Text1.Text = "22 11 33" End Sub 调试通过的,别忘了采纳
无聊也不聊
2024-10-23 07:40:50
dim Arr Arr=split(TEXT1.TEXT," ") s=0 for i= 0 to Ubound(Arr)-1 S=S+VAL(Arr(i) next i
A=S/ubound(Arr)
⊿半季离殇
2024-10-23 07:40:51
处理方法如下: Private Function AverageA(A As Variant) As Double Dim s As Double s = 0 For i = 0 To UBound(A) s = s + Val(A(i)) Next If i <> 0 Then AverageA = s / i Else AverageA = 0 End Function Private Sub Command1_Click() Dim A A = Split(Trim(Text1.Text)) Text2.Text = AverageA(A) End Sub