用vb 最好完整一点
Private Sub Command1_Click()
Dim j, n, s As Integer
n = 100
s = 0
For j = 1 To n
s = s + f(j)
Next
Print "S=1+(1+2)+(1+2+3)+…+(1+2+3+4+…+100)=", s
End Sub
Function f(Bybal n As Integer) As Integer
Dim i, t As Integer
s = 0
For i = 1 To n
t = t + i
Next
f = t
End Function------这个是网络找的,输入vb一直有错
vb编程:计算1+(1+2)+(1+2+3)+...+(1+2+3+...+n)
Private Sub Form_Click()Dim I as Integer, S as Long, Sum as Long N=10 For i=1 to N S=S+I Sum=Sum+S Next Print Sum 'N=10的结果 End Sub
用VB写设计程序代码,求:s=1+(1+2)+(1+2+3)+??+(1+2+3+??+n)的值。
sum2 = sumF(100)Print Print "sum1="; sum1 Print "sum2="; sum2 End Sub 运行结果是:sum1=5.187377 sum2=5.187377
编程:从键盘输入正整数n,输出1+(1+2)+(1+2+3)+...+(1+2+3+...+n...
sum+=sum_n(i);printf("sum = %d\\n",sum);}这样只是最简单的一种,效率不高,实际情况做的时候通常是把表达式整理成一个多项表达式来直接做运算,比如说你的那几个1+(1+2)...你可以整理成一个带n的单项式,然后只需要求这个式子的值就行了 ...
vb中怎样编写“1+(1+2)+(1+2+3)+(1++2+3+4)+。。。”程序
sum2 = sum2 + sum1 Next i End Sub sum2为结果
求在VB中如何输出1+(1+2)+(1+2+3)...(1+2+...n)的式子(在线等)
a = ""b = ""n = Val(InputBox("请输入一个数:"))For i = 1 To n For j = 1 To i If j = 1 Then a = 1 Else a = a & "+" & j s = s + j Next j If b = "" Then b = a Else b = b & "+" & "(" & a & ")"Next i MsgBox b & "=" & s ...
编写一个程序,使用函数过程的方式求和数s=1+(1+2)+(1+2+3)+…+(1+...
Sub Main()Dim n As Integer Dim sum, nsum As Integer 'sum 记录总和,nsum记录1+2+..N的和 Console.WriteLine("please input n")Dim tmpStr As String tmpStr = Console.ReadLine()'判断是否是int类型的,'IsNumeric(tmpStr)判断是否是数字类型,InStr(tmpStr, ".") 判断是否有小数点 If ...
vb程序设计,一道题s=1+(1+2)+(1+2+3)+...+(1+2+3+...+n)输入n
望采纳。。。
编程实现求Sum=1+(1+2)+(1+2+3)+(1+2+3+4)+ …… +(1+2+3+4+ … +...
isum=0 jsum=0 read(*,*) n do i=1,n do j=1,i jsum=jsum+j enddo isum=isum+jsum jsum=0 enddo print*,isum end 这是fortran程序,自己改成vb语法或其他你自己需要的语法即可
编写信息1+1+2+1+2+3.. 求累加到几项时和超过五万 VB
加到100项时,整好是50000,可以用以下代码测试。Public Sub ad()Dim countnum As Integer = 0 Dim aa As Integer = 0 For i As Int16 = 1 To 5000 aa = i For x As Int16 = 1 To i countnum += 1 If countnum = 5000 Then Exit For End If Next If countnum = 5000 Then ...
编程实现求Sum=1+(1+2)+(1+2+3)+(1+2+3+4)+ …… +(1+2+3+4+ … +...
Sub test()n = InputBox("输入一个整数")su = 0 For i = 1 To n * 1 For j = 1 To i - 1 su = su + j Next su = su + i Next Print su End Sub