求用vb实现1到100的和加上1到50的平方和加上1到1/10的和的代码是多少?

求用vb实现1到100的和加上1到50的平方和加上1到1/10的和的代码是多少?

第1个回答  2010-04-20
现在窗口画一个Command1
代码:
Private Sub Command1_Click()
Dim s As single
s = 0
For i = 1 To 100
s = s + i
Next
For i = 1 To 50
s = s + i ^ 2
Next
For i = 1 To 10
s = s + 1 / i
Next
MsgBox s
End Sub
第2个回答  2010-04-19
Private Sub Command1_Click()
Dim s As Double
s = 0
For i = 1 To 100
s = s + i
Next
For i = 1 To 50
s = s + i ^ 2
Next
For i = 1 To 10
s = s + 1 / i
Next
MsgBox s
End Sub本回答被提问者采纳
第3个回答  2019-12-15
sub
平方和()
dim
sum
dim
i
as
long
sum
=0
for
i
=
1
to
100
sum
=
sum
+
i
*
i
next
i
end
sub

求用vb实现1到100的和加上1到50的平方和加上1到1\/10的和的代码是多少...
代码:Private Sub Command1_Click()Dim s As single s = 0 For i = 1 To 100 s = s + i Next For i = 1 To 50 s = s + i ^ 2 Next For i = 1 To 10 s = s + 1 \/ i Next MsgBox s End Sub

VB程序 求1到100之间的自然数的平方和
'Option Explicit '获取随机数 Public Sub GetRndStr(min As Integer, max As Integer, b() As Integer)Dim i As Integer, m As Integer i = 1 s = Fix(min + Rnd * max) & " "b(0) = Val(s)Do Randomize m = Fix(min + Rnd * max)If InStr(1, s, m) = 0 Then i =...

用vb的for语句求1到100的平方的和
NEXT I

求1-10的平方和。vb编程给代码
For i As Integer = 1 To 10 sum += i * i Next Console.WriteLine("1-10的平方和为:" & sum)Console.ReadLine()End Sub End Module 这段代码中,我们首先定义了一个整型变量`sum`,用于存储平方和的累加结果。然后,使用`For`循环从1遍历到10,计算每个数的平方,并将其累加到`sum`中。

vb中输出1-100的平方和
Private Sub Command1_Click()Dim i As Integer, sum As Long For i = 1 To 100 sum = sum + i ^ 2 Next MsgBox sum End Sub

怎么用VB求N个数的和,平方和,平均值和平方和的平方根?代码是什么?求高 ...
n = InputBox("输入个数")ReDim a(n)For i = 1 To n a(i) = InputBox("输入数值")Next i For i = 1 To n s = s + a(i)Next i Print "和="; s Print "平均值="; s \/ n s = 0 For i = 1 To n s = s + a(i) ^ 2 Next i Print "平方和="; s Print ...

编写VB程序,打印1到100所有数的平方,平方根,自然对数,e指数的数用表
Private Sub Command1_Click()Dim p As Long, g As Single, l As Single, e As Double Print "数值", "平方 ", "平方根 ", "自然对数 ", " e指数"For i = 1 To 100 p = i ^ 2 g = Sqr(i)l = Log(i)e = Exp(i)Print i, p, g, l, e Next End Sub ...

vb用列表框输出1-50之间的平方、平方根、自然对数和e指数数学用表,要完...
Private Sub Form_Load()Dim i As Integer For i = 1 To 50 List1.AddItem i & vbTab & i * i & vbTab & Sqr(i) & vbTab & Log(i) & vbTab & Exp(i)Next End Sub

vb中 怎么输入 在列表框内 1到50的平方 平方根 自然对数 和 e的指数...
Private Sub Command1_Click()For i = 1 To 50 List1.AddItem i ^ 2 '平方 List1.AddItem Sqr(i) '平方根 List1.AddItem Log(i) '自然对数 List1.AddItem Exp(i) '返回 e(自然对数的底)的幂次方 Next End Sub

VB程序 打印1~100所有数的平方,平方根,自然对数,e指数的数学用表在...
Private Sub Command3_Click() Dim s As String s = "" For i = 1 To 100 s = s & i & "^2=" & i ^ 2 & " sqrt(" & i & ")=" & Sqr(i) & " e^" & i & "=" & Exp(i) & vbCrLf Next i Text1.Text = sEnd Sub ...

相似回答