vb求和语言

vb求和语言,第1张

Private Sub Command1_Click()

a = Val(Text1)

s = Len(a)

Sum = 0

For i = 1 To s

Sum = Sum + a Mod 10

a = a \ 10

Next i

Text2 = Str(Sum)

End Sub

Private Sub Command2_Click()

Text1 = ""

Text1SetFocus

Text2 = ""

End Sub

Private Sub Command3_Click()

End

End Sub

Private Sub Command1_Click()

Dim a(1 To 10) As Double

Dim i As Integer

Dim max As Integer

Dim min As Integer

Dim s As Integer

i = 1

While i <= 10

a(i) = InputBox("输入数字")

i = i + 1

Wend

For i = 1 To 10

s = s + a(i)

Print a(i);

Next i

Print "和是:" & s

Print "平均值是:" & s / 10

max = a(1)

min = a(1)

For i = 1 To 10

If a(i) > max Then

max = a(i)

End If

If a(i) < min Then

min = a(i)

End If

Next i

Print "最大是:" & max

Print "最小是:" & min

End Sub

function suma() as double

dim i as long

for i = lbound(a) to ubound(a)

suma = suma + a(i)

next

end function

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/12181541.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-21
下一篇 2023-05-21

发表评论

登录后才能评论

评论列表(0条)

保存